From df45824c5983532176eb8579e326bb681a62270a Mon Sep 17 00:00:00 2001 From: Benoit Alessandroni <benoit@happy-dev.fr> Date: Mon, 17 Jul 2023 14:37:54 +0200 Subject: [PATCH 01/66] fix: possibility to modify the editable label button --- src/new-widgets/templatesDependencies/editableMixin.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/new-widgets/templatesDependencies/editableMixin.ts b/src/new-widgets/templatesDependencies/editableMixin.ts index 9137d86d..b6e853c0 100644 --- a/src/new-widgets/templatesDependencies/editableMixin.ts +++ b/src/new-widgets/templatesDependencies/editableMixin.ts @@ -17,6 +17,10 @@ const EditableMixin = { valueId: { type: String, default: '' + }, + buttonLabel: { + type: String, + default: 'Modifier' } }, created() { @@ -25,10 +29,7 @@ const EditableMixin = { addEditButton(template, listTemplateAdditions: Function[]) { let newTemplate: any = null; if (this.editable !== null) { - newTemplate = html` - ${template} - <button @click=${this.activateEditableField.bind(this)}>Modifier</button> - `; + newTemplate = html`${template}<button @click=${this.activateEditableField.bind(this)}>${this.buttonLabel}</button>`; } const nextProcessor = listTemplateAdditions.shift(); if(nextProcessor) nextProcessor(newTemplate || template, listTemplateAdditions); -- GitLab From fe928302096fbeca2e59e779f71f7276e469fa05 Mon Sep 17 00:00:00 2001 From: Anastasia Kryukova <anastasia.kryukova@protonmail.com> Date: Fri, 16 Aug 2024 15:17:15 +0200 Subject: [PATCH 02/66] fix: display file name if input is not empty --- cypress/e2e/e2e/solid-form-file.cy.ts | 9 ++++++++- src/new-widgets/templates/formTemplatesDirectory.ts | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/e2e/solid-form-file.cy.ts b/cypress/e2e/e2e/solid-form-file.cy.ts index c48f2cfd..2cabf4f4 100644 --- a/cypress/e2e/e2e/solid-form-file.cy.ts +++ b/cypress/e2e/e2e/solid-form-file.cy.ts @@ -5,7 +5,7 @@ describe('solid-form-file test', { testIsolation: false }, function() { }); it('upload file with solid-form-file', function() { - cy.get('#form-file [name=picture]+input[type=file]').uploadFile('../../fake-image.svg') + cy.get('#form-file [name=picture] input[type=file]').uploadFile('../../fake-image.svg') cy.get('#form-file input[name=picture]').should($i => { expect($i.val()).to.match(/\/upload\/[0-9a-f]+.jpg$/) }) @@ -52,4 +52,11 @@ describe('solid-form-file test', { testIsolation: false }, function() { cy.get('#form-required-file solid-form-file input[type=text]').should('have.attr', 'required') cy.get('#form-required-file solid-form-file input[type=file]').should('not.have.attr', 'required') }) + + it('displays file name if source not empty', function() { + cy.visit('/examples/e2e/solid-form-file.html'); // if not then page is not updated, and another file is uploaded from the prev test + cy.get('#form-file solid-form-file[name=picture] a[href="../../upload/fruits.jpg"]').contains("fruits.jpg") + cy.get('#reset-file solid-form-file[name=picture] a[href="../../upload/fruits.jpg"]').contains("fruits.jpg") + cy.get('#form-required-file solid-form-file[name=picture] a[href="../../upload/fruits.jpg"]').contains("fruits.jpg") + }) }) \ No newline at end of file diff --git a/src/new-widgets/templates/formTemplatesDirectory.ts b/src/new-widgets/templates/formTemplatesDirectory.ts index be8d15e7..74f334fb 100644 --- a/src/new-widgets/templates/formTemplatesDirectory.ts +++ b/src/new-widgets/templates/formTemplatesDirectory.ts @@ -303,6 +303,11 @@ export const formTemplates = { name=${ifDefined(attributes.name)} value=${value || ''} > + <a + href=${value || ''} + ?hidden=${value === ''} + >${ ((value !== '') ? decodeURI(value.split("/").pop() as string) : '' ) }</a> + <input type="file" id=${ifDefined(attributes.id)} -- GitLab From 44ba633250485fc38e9789e430403c77929d2bfc Mon Sep 17 00:00:00 2001 From: Anastasia Kryukova <anastasia.kryukova@protonmail.com> Date: Tue, 10 Sep 2024 19:53:31 +0200 Subject: [PATCH 03/66] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c158bd76..7d1c13d7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,6 +12,7 @@ default: variables: npm_config_cache: "$CI_PROJECT_DIR/.npm" CYPRESS_CACHE_FOLDER: "$CI_PROJECT_DIR/cache/Cypress" + VITE_DEBUG: false # cache using branch name # https://gitlab.com/help/ci/caching/index.md -- GitLab From ca932159e4ddb45adc6aefc9cf7525b9acfa3f64 Mon Sep 17 00:00:00 2001 From: Anastasia Kryukova <anastasia.kryukova@protonmail.com> Date: Wed, 11 Sep 2024 14:58:28 +0200 Subject: [PATCH 04/66] rollback .gitlab-ci.yml file --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7d1c13d7..c158bd76 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,7 +12,6 @@ default: variables: npm_config_cache: "$CI_PROJECT_DIR/.npm" CYPRESS_CACHE_FOLDER: "$CI_PROJECT_DIR/cache/Cypress" - VITE_DEBUG: false # cache using branch name # https://gitlab.com/help/ci/caching/index.md -- GitLab From 5d3e7f34b5110ff2f13b8117a2f686108382983a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Wed, 25 Sep 2024 13:49:38 +0200 Subject: [PATCH 05/66] update dependencies (minor) --- package-lock.json | 939 +++++++++++++++++++++++++++++----------------- package.json | 36 +- 2 files changed, 605 insertions(+), 370 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0e09e391..50cfb51d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,35 +14,35 @@ "devDependencies": { "@rckeller/cypress-unfetch": "^1.0.1", "@types/autolinker": "^2.0.0", - "@types/leaflet": "^1.5.21", - "@types/leaflet.markercluster": "^1.4.3", - "@types/markdown-it": "^12.0.1", - "@types/node": "^20.5.0", - "@types/pubsub-js": "^1.8.2", - "@types/quill": "^2.0.4", - "autolinker": "^3.14.2", + "@types/leaflet": "^1.9.12", + "@types/leaflet.markercluster": "^1.5.4", + "@types/markdown-it": "^12.2.3", + "@types/node": "^20.16.7", + "@types/pubsub-js": "^1.8.6", + "@types/quill": "^2.0.14", + "autolinker": "^3.16.2", "cypress": "^13.2.0", "cypress-plugin-tab": "^1.0.5", "delta-markdown-for-quill": "0.0.9", "dialog-polyfill": "^0.5.6", - "express": "^4.17.1", + "express": "^4.21.0", "find-free-port": "^2.0.0", - "fuse.js": "^6.4.6", - "jsonld": "^8.3.1", + "fuse.js": "^6.6.2", + "jsonld": "^8.3.2", "jsonld-context-parser": "^1.3.4", - "leaflet": "1.7.1", + "leaflet": "1.9.4", "leaflet.markercluster": "1.5.3", - "lit-html": "^1.3.0", - "markdown-it": "^12.0.4", + "lit-html": "^1.4.1", + "markdown-it": "^12.3.2", "markdown-it-link-attributes": "4.0.1", - "pubsub-js": "^1.9.2", + "pubsub-js": "^1.9.4", "quill": "^1.3.7", "quill-delta-to-markdown": "^0.6.0", - "semver": "7.5.4", - "slim-select": "^1.27.0", - "tui-calendar": "^1.13.0", + "semver": "7.6.3", + "slim-select": "^1.27.1", + "tui-calendar": "^1.15.3", "typescript": "^4.9.5", - "vite": "^5.0.12" + "vite": "^5.4.8" } }, "node_modules/@colors/colors": { @@ -133,13 +133,14 @@ } }, "node_modules/@esbuild/aix-ppc64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.12.tgz", - "integrity": "sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", + "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", "cpu": [ "ppc64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "aix" @@ -149,13 +150,14 @@ } }, "node_modules/@esbuild/android-arm": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.12.tgz", - "integrity": "sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz", + "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", "cpu": [ "arm" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "android" @@ -165,13 +167,14 @@ } }, "node_modules/@esbuild/android-arm64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.12.tgz", - "integrity": "sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", + "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "android" @@ -181,13 +184,14 @@ } }, "node_modules/@esbuild/android-x64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.12.tgz", - "integrity": "sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz", + "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "android" @@ -197,13 +201,14 @@ } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.12.tgz", - "integrity": "sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", + "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "darwin" @@ -213,13 +218,14 @@ } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.12.tgz", - "integrity": "sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", + "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "darwin" @@ -229,13 +235,14 @@ } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.12.tgz", - "integrity": "sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", + "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "freebsd" @@ -245,13 +252,14 @@ } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.12.tgz", - "integrity": "sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", + "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "freebsd" @@ -261,13 +269,14 @@ } }, "node_modules/@esbuild/linux-arm": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.12.tgz", - "integrity": "sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", + "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", "cpu": [ "arm" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -277,13 +286,14 @@ } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.12.tgz", - "integrity": "sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", + "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -293,13 +303,14 @@ } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.12.tgz", - "integrity": "sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", + "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", "cpu": [ "ia32" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -309,13 +320,14 @@ } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.12.tgz", - "integrity": "sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", + "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", "cpu": [ "loong64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -325,13 +337,14 @@ } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.12.tgz", - "integrity": "sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", + "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", "cpu": [ "mips64el" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -341,13 +354,14 @@ } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.12.tgz", - "integrity": "sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", + "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", "cpu": [ "ppc64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -357,13 +371,14 @@ } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.12.tgz", - "integrity": "sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", + "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", "cpu": [ "riscv64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -373,13 +388,14 @@ } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.12.tgz", - "integrity": "sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", + "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", "cpu": [ "s390x" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -389,13 +405,14 @@ } }, "node_modules/@esbuild/linux-x64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.12.tgz", - "integrity": "sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", + "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -405,13 +422,14 @@ } }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.12.tgz", - "integrity": "sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", + "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "netbsd" @@ -421,13 +439,14 @@ } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.12.tgz", - "integrity": "sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", + "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "openbsd" @@ -437,13 +456,14 @@ } }, "node_modules/@esbuild/sunos-x64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.12.tgz", - "integrity": "sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", + "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "sunos" @@ -453,13 +473,14 @@ } }, "node_modules/@esbuild/win32-arm64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.12.tgz", - "integrity": "sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", + "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "win32" @@ -469,13 +490,14 @@ } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.12.tgz", - "integrity": "sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", + "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", "cpu": [ "ia32" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "win32" @@ -485,13 +507,14 @@ } }, "node_modules/@esbuild/win32-x64": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.12.tgz", - "integrity": "sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", + "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "win32" @@ -589,169 +612,224 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.9.6", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.9.6.tgz", - "integrity": "sha512-MVNXSSYN6QXOulbHpLMKYi60ppyO13W9my1qogeiAqtjb2yR4LSmfU2+POvDkLzhjYLXz9Rf9+9a3zFHW1Lecg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.4.tgz", + "integrity": "sha512-Fxamp4aEZnfPOcGA8KSNEohV8hX7zVHOemC8jVBoBUHu5zpJK/Eu3uJwt6BMgy9fkvzxDaurgj96F/NiLukF2w==", "cpu": [ "arm" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "android" ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.9.6", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.9.6.tgz", - "integrity": "sha512-T14aNLpqJ5wzKNf5jEDpv5zgyIqcpn1MlwCrUXLrwoADr2RkWA0vOWP4XxbO9aiO3dvMCQICZdKeDrFl7UMClw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.4.tgz", + "integrity": "sha512-VXoK5UMrgECLYaMuGuVTOx5kcuap1Jm8g/M83RnCHBKOqvPPmROFJGQaZhGccnsFtfXQ3XYa4/jMCJvZnbJBdA==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "android" ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.9.6", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.9.6.tgz", - "integrity": "sha512-CqNNAyhRkTbo8VVZ5R85X73H3R5NX9ONnKbXuHisGWC0qRbTTxnF1U4V9NafzJbgGM0sHZpdO83pLPzq8uOZFw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.4.tgz", + "integrity": "sha512-xMM9ORBqu81jyMKCDP+SZDhnX2QEVQzTcC6G18KlTQEzWK8r/oNZtKuZaCcHhnsa6fEeOBionoyl5JsAbE/36Q==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "darwin" ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.9.6", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.9.6.tgz", - "integrity": "sha512-zRDtdJuRvA1dc9Mp6BWYqAsU5oeLixdfUvkTHuiYOHwqYuQ4YgSmi6+/lPvSsqc/I0Omw3DdICx4Tfacdzmhog==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.4.tgz", + "integrity": "sha512-aJJyYKQwbHuhTUrjWjxEvGnNNBCnmpHDvrb8JFDbeSH3m2XdHcxDd3jthAzvmoI8w/kSjd2y0udT+4okADsZIw==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "darwin" ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.9.6", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.9.6.tgz", - "integrity": "sha512-oNk8YXDDnNyG4qlNb6is1ojTOGL/tRhbbKeE/YuccItzerEZT68Z9gHrY3ROh7axDc974+zYAPxK5SH0j/G+QQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.4.tgz", + "integrity": "sha512-j63YtCIRAzbO+gC2L9dWXRh5BFetsv0j0va0Wi9epXDgU/XUi5dJKo4USTttVyK7fGw2nPWK0PbAvyliz50SCQ==", "cpu": [ "arm" ], "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.4.tgz", + "integrity": "sha512-dJnWUgwWBX1YBRsuKKMOlXCzh2Wu1mlHzv20TpqEsfdZLb3WoJW2kIEsGwLkroYf24IrPAvOT/ZQ2OYMV6vlrg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.9.6", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.9.6.tgz", - "integrity": "sha512-Z3O60yxPtuCYobrtzjo0wlmvDdx2qZfeAWTyfOjEDqd08kthDKexLpV97KfAeUXPosENKd8uyJMRDfFMxcYkDQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.4.tgz", + "integrity": "sha512-AdPRoNi3NKVLolCN/Sp4F4N1d98c4SBnHMKoLuiG6RXgoZ4sllseuGioszumnPGmPM2O7qaAX/IJdeDU8f26Aw==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.9.6", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.9.6.tgz", - "integrity": "sha512-gpiG0qQJNdYEVad+1iAsGAbgAnZ8j07FapmnIAQgODKcOTjLEWM9sRb+MbQyVsYCnA0Im6M6QIq6ax7liws6eQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.4.tgz", + "integrity": "sha512-Gl0AxBtDg8uoAn5CCqQDMqAx22Wx22pjDOjBdmG0VIWX3qUBHzYmOKh8KXHL4UpogfJ14G4wk16EQogF+v8hmA==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.4.tgz", + "integrity": "sha512-3aVCK9xfWW1oGQpTsYJJPF6bfpWfhbRnhdlyhak2ZiyFLDaayz0EP5j9V1RVLAAxlmWKTDfS9wyRyY3hvhPoOg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.9.6", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.9.6.tgz", - "integrity": "sha512-+uCOcvVmFUYvVDr27aiyun9WgZk0tXe7ThuzoUTAukZJOwS5MrGbmSlNOhx1j80GdpqbOty05XqSl5w4dQvcOA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.4.tgz", + "integrity": "sha512-ePYIir6VYnhgv2C5Xe9u+ico4t8sZWXschR6fMgoPUK31yQu7hTEJb7bCqivHECwIClJfKgE7zYsh1qTP3WHUA==", "cpu": [ "riscv64" ], "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.4.tgz", + "integrity": "sha512-GqFJ9wLlbB9daxhVlrTe61vJtEY99/xB3C8e4ULVsVfflcpmR6c8UZXjtkMA6FhNONhj2eA5Tk9uAVw5orEs4Q==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.9.6", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.9.6.tgz", - "integrity": "sha512-HUNqM32dGzfBKuaDUBqFB7tP6VMN74eLZ33Q9Y1TBqRDn+qDonkAUyKWwF9BR9unV7QUzffLnz9GrnKvMqC/fw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.4.tgz", + "integrity": "sha512-87v0ol2sH9GE3cLQLNEy0K/R0pz1nvg76o8M5nhMR0+Q+BBGLnb35P0fVz4CQxHYXaAOhE8HhlkaZfsdUOlHwg==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.9.6", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.9.6.tgz", - "integrity": "sha512-ch7M+9Tr5R4FK40FHQk8VnML0Szi2KRujUgHXd/HjuH9ifH72GUmw6lStZBo3c3GB82vHa0ZoUfjfcM7JiiMrQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.4.tgz", + "integrity": "sha512-UV6FZMUgePDZrFjrNGIWzDo/vABebuXBhJEqrHxrGiU6HikPy0Z3LfdtciIttEUQfuDdCn8fqh7wiFJjCNwO+g==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.9.6", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.9.6.tgz", - "integrity": "sha512-VD6qnR99dhmTQ1mJhIzXsRcTBvTjbfbGGwKAHcu+52cVl15AC/kplkhxzW/uT0Xl62Y/meBKDZvoJSJN+vTeGA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.4.tgz", + "integrity": "sha512-BjI+NVVEGAXjGWYHz/vv0pBqfGoUH0IGZ0cICTn7kB9PyjrATSkX+8WkguNjWoj2qSr1im/+tTGRaY+4/PdcQw==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "win32" ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.9.6", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.9.6.tgz", - "integrity": "sha512-J9AFDq/xiRI58eR2NIDfyVmTYGyIZmRcvcAoJ48oDld/NTR8wyiPUu2X/v1navJ+N/FGg68LEbX3Ejd6l8B7MQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.4.tgz", + "integrity": "sha512-SiWG/1TuUdPvYmzmYnmd3IEifzR61Tragkbx9D3+R8mzQqDBz8v+BvZNDlkiTtI9T15KYZhP0ehn3Dld4n9J5g==", "cpu": [ "ia32" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "win32" ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.9.6", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.9.6.tgz", - "integrity": "sha512-jqzNLhNDvIZOrt69Ce4UjGRpXJBzhUBzawMwnaDAwyHriki3XollsewxWzOzz+4yOFDkuJHtTsZFwMxhYJWmLQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.4.tgz", + "integrity": "sha512-j8pPKp53/lq9lMXN57S8cFz0MynJk8OWNuUnXct/9KCpKU7DgU3bYMJhwWmcqC0UU29p8Lr0/7KEVcaM6bf47Q==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "win32" @@ -771,7 +849,8 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@types/geojson": { "version": "7946.0.10", @@ -780,19 +859,21 @@ "dev": true }, "node_modules/@types/leaflet": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/@types/leaflet/-/leaflet-1.9.3.tgz", - "integrity": "sha512-Caa1lYOgKVqDkDZVWkto2Z5JtVo09spEaUt2S69LiugbBpoqQu92HYFMGUbYezZbnBkyOxMNPXHSgRrRY5UyIA==", + "version": "1.9.12", + "resolved": "https://registry.npmjs.org/@types/leaflet/-/leaflet-1.9.12.tgz", + "integrity": "sha512-BK7XS+NyRI291HIo0HCfE18Lp8oA30H1gpi1tf0mF3TgiCEzanQjOqNZ4x126SXzzi2oNSZhZ5axJp1k0iM6jg==", "dev": true, + "license": "MIT", "dependencies": { "@types/geojson": "*" } }, "node_modules/@types/leaflet.markercluster": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/@types/leaflet.markercluster/-/leaflet.markercluster-1.5.1.tgz", - "integrity": "sha512-gzJzP10qO6Zkts5QNVmSAEDLYicQHTEBLT9HZpFrJiSww9eDAs5OWHvIskldf41MvDv1gbMukuEBQEawHn+wtA==", + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@types/leaflet.markercluster/-/leaflet.markercluster-1.5.4.tgz", + "integrity": "sha512-tfMP8J62+wfsVLDLGh5Zh1JZxijCaBmVsMAX78MkLPwvPitmZZtSin5aWOVRhZrCS+pEOZwNzexbfWXlY+7yjg==", "dev": true, + "license": "MIT", "dependencies": { "@types/leaflet": "*" } @@ -820,25 +901,38 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.5.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.0.tgz", - "integrity": "sha512-Mgq7eCtoTjT89FqNoTzzXg2XvCi5VMhRV6+I2aYanc6kQCBImeNaAYRs/DyoVqk1YEUJK5gN9VO7HRIdz4Wo3Q==", - "dev": true + "version": "20.16.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.7.tgz", + "integrity": "sha512-QkDQjAY3gkvJNcZOWwzy3BN34RweT0OQ9zJyvLCU0kSK22dO2QYh/NHGfbEAYylPYzRB1/iXcojS79wOg5gFSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.19.2" + } + }, + "node_modules/@types/node/node_modules/undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "dev": true, + "license": "MIT" }, "node_modules/@types/pubsub-js": { - "version": "1.8.3", - "resolved": "https://registry.npmjs.org/@types/pubsub-js/-/pubsub-js-1.8.3.tgz", - "integrity": "sha512-6BqY04dh2UV1dNV690tyJVJYQ0U6qBH4tU+FCwY1Mhl8jOPOP9qiIvgLnB59cVik/E6/R002oXZpGiDm+2C8eA==", - "dev": true + "version": "1.8.6", + "resolved": "https://registry.npmjs.org/@types/pubsub-js/-/pubsub-js-1.8.6.tgz", + "integrity": "sha512-Kwug5cwV0paUDm/NfwDx1sp9xI0bGIvmWJjJWCU8NngkCCMt3EIC7oPDvb6fV7BR8kPpFyyBu4D11bda/2MdPA==", + "dev": true, + "license": "MIT" }, "node_modules/@types/quill": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/@types/quill/-/quill-2.0.10.tgz", - "integrity": "sha512-L6OHONEj2v4NRbWQOsn7j1N0SyzhRR3M4g1M6j/uuIwIsIW2ShWHhwbqNvH8hSmVktzqu0lITfdnqVOQ4qkrhA==", + "version": "2.0.14", + "resolved": "https://registry.npmjs.org/@types/quill/-/quill-2.0.14.tgz", + "integrity": "sha512-zvoXCRnc2Dl8g+7/9VSAmRWPN6oH+MVhTPizmCR+GJCITplZ5VRVzMs4+a/nOE3yzNwEZqylJJrMB07bwbM1/g==", "dev": true, + "license": "MIT", "dependencies": { "parchment": "^1.1.2", - "quill-delta": "^4.0.1" + "quill-delta": "^5.1.0" } }, "node_modules/@types/sinonjs__fake-timers": { @@ -1109,6 +1203,48 @@ "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", "dev": true }, + "node_modules/body-parser": { + "version": "1.20.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", + "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", + "dev": true, + "license": "MIT", + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.13.0", + "raw-body": "2.5.2", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/body-parser/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/body-parser/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true, + "license": "MIT" + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -1165,6 +1301,7 @@ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.8" } @@ -1179,14 +1316,20 @@ } }, "node_modules/call-bind": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz", - "integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", + "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", "dev": true, + "license": "MIT", "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.1", - "set-function-length": "^1.1.1" + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -1357,15 +1500,17 @@ "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.6" } }, "node_modules/cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.6" } @@ -1640,17 +1785,21 @@ } }, "node_modules/define-data-property": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz", - "integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", "dev": true, + "license": "MIT", "dependencies": { - "get-intrinsic": "^1.2.1", - "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.0" + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" }, "engines": { "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/define-properties": { @@ -1715,6 +1864,7 @@ "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.8" } @@ -1724,6 +1874,7 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.8", "npm": "1.2.8000 || >= 1.4.16" @@ -1736,10 +1887,11 @@ "dev": true }, "node_modules/dompurify": { - "version": "2.4.7", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.4.7.tgz", - "integrity": "sha512-kxxKlPEDa6Nc5WJi+qRgPbOAbgTpSULL+vI3NUXsZMlkJxTqYI9wg5ZTay2sFrdZRWHPWNi+EdAhcJf81WtoMQ==", - "dev": true + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.5.6.tgz", + "integrity": "sha512-zUTaUBO8pY4+iJMPE1B9XlO2tXVYIcEA4SNGtvDELzTSCQO7RzH+j7S180BmhmJId78lqGU2z19vgVx2Sxs/PQ==", + "dev": true, + "license": "(MPL-2.0 OR Apache-2.0)" }, "node_modules/ecc-jsbn": { "version": "0.1.2", @@ -1755,7 +1907,8 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/emoji-regex": { "version": "8.0.0", @@ -1764,10 +1917,11 @@ "dev": true }, "node_modules/encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.8" } @@ -1821,12 +1975,36 @@ "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==", "dev": true }, + "node_modules/es-define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/esbuild": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.12.tgz", - "integrity": "sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", + "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", "dev": true, "hasInstallScript": true, + "license": "MIT", "bin": { "esbuild": "bin/esbuild" }, @@ -1834,36 +2012,37 @@ "node": ">=12" }, "optionalDependencies": { - "@esbuild/aix-ppc64": "0.19.12", - "@esbuild/android-arm": "0.19.12", - "@esbuild/android-arm64": "0.19.12", - "@esbuild/android-x64": "0.19.12", - "@esbuild/darwin-arm64": "0.19.12", - "@esbuild/darwin-x64": "0.19.12", - "@esbuild/freebsd-arm64": "0.19.12", - "@esbuild/freebsd-x64": "0.19.12", - "@esbuild/linux-arm": "0.19.12", - "@esbuild/linux-arm64": "0.19.12", - "@esbuild/linux-ia32": "0.19.12", - "@esbuild/linux-loong64": "0.19.12", - "@esbuild/linux-mips64el": "0.19.12", - "@esbuild/linux-ppc64": "0.19.12", - "@esbuild/linux-riscv64": "0.19.12", - "@esbuild/linux-s390x": "0.19.12", - "@esbuild/linux-x64": "0.19.12", - "@esbuild/netbsd-x64": "0.19.12", - "@esbuild/openbsd-x64": "0.19.12", - "@esbuild/sunos-x64": "0.19.12", - "@esbuild/win32-arm64": "0.19.12", - "@esbuild/win32-ia32": "0.19.12", - "@esbuild/win32-x64": "0.19.12" + "@esbuild/aix-ppc64": "0.21.5", + "@esbuild/android-arm": "0.21.5", + "@esbuild/android-arm64": "0.21.5", + "@esbuild/android-x64": "0.21.5", + "@esbuild/darwin-arm64": "0.21.5", + "@esbuild/darwin-x64": "0.21.5", + "@esbuild/freebsd-arm64": "0.21.5", + "@esbuild/freebsd-x64": "0.21.5", + "@esbuild/linux-arm": "0.21.5", + "@esbuild/linux-arm64": "0.21.5", + "@esbuild/linux-ia32": "0.21.5", + "@esbuild/linux-loong64": "0.21.5", + "@esbuild/linux-mips64el": "0.21.5", + "@esbuild/linux-ppc64": "0.21.5", + "@esbuild/linux-riscv64": "0.21.5", + "@esbuild/linux-s390x": "0.21.5", + "@esbuild/linux-x64": "0.21.5", + "@esbuild/netbsd-x64": "0.21.5", + "@esbuild/openbsd-x64": "0.21.5", + "@esbuild/sunos-x64": "0.21.5", + "@esbuild/win32-arm64": "0.21.5", + "@esbuild/win32-ia32": "0.21.5", + "@esbuild/win32-x64": "0.21.5" } }, "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/escape-string-regexp": { "version": "1.0.5", @@ -1879,6 +2058,7 @@ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.6" } @@ -1940,37 +2120,38 @@ } }, "node_modules/express": { - "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "version": "4.21.0", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.0.tgz", + "integrity": "sha512-VqcNGcj/Id5ZT1LZ/cfihi3ttTn+NJmkli2eZADigjq29qTlWi/hAQ43t/VLPq8+UX06FCEx3ByOYet6ZFblng==", "dev": true, + "license": "MIT", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.1", + "body-parser": "1.20.3", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "etag": "~1.8.1", - "finalhandler": "1.2.0", + "finalhandler": "1.3.1", "fresh": "0.5.2", "http-errors": "2.0.0", - "merge-descriptors": "1.0.1", + "merge-descriptors": "1.0.3", "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.7", + "path-to-regexp": "0.1.10", "proxy-addr": "~2.0.7", - "qs": "6.11.0", + "qs": "6.13.0", "range-parser": "~1.2.1", "safe-buffer": "5.2.1", - "send": "0.18.0", - "serve-static": "1.15.0", + "send": "0.19.0", + "serve-static": "1.16.2", "setprototypeof": "1.2.0", "statuses": "2.0.1", "type-is": "~1.6.18", @@ -1981,35 +2162,12 @@ "node": ">= 0.10.0" } }, - "node_modules/express/node_modules/body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", - "dev": true, - "dependencies": { - "bytes": "3.1.2", - "content-type": "~1.0.4", - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "on-finished": "2.4.1", - "qs": "6.11.0", - "raw-body": "2.5.1", - "type-is": "~1.6.18", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8", - "npm": "1.2.8000 || >= 1.4.16" - } - }, "node_modules/express/node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, + "license": "MIT", "dependencies": { "ms": "2.0.0" } @@ -2018,22 +2176,8 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "dev": true - }, - "node_modules/express/node_modules/raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", "dev": true, - "dependencies": { - "bytes": "3.1.2", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8" - } + "license": "MIT" }, "node_modules/extend": { "version": "3.0.2", @@ -2071,10 +2215,11 @@ ] }, "node_modules/fast-diff": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", - "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", - "dev": true + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true, + "license": "Apache-2.0" }, "node_modules/fd-slicer": { "version": "1.1.0", @@ -2124,13 +2269,14 @@ } }, "node_modules/finalhandler": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", - "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", + "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", "dev": true, + "license": "MIT", "dependencies": { "debug": "2.6.9", - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "on-finished": "2.4.1", "parseurl": "~1.3.3", @@ -2146,6 +2292,7 @@ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, + "license": "MIT", "dependencies": { "ms": "2.0.0" } @@ -2154,7 +2301,8 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/find-free-port": { "version": "2.0.0", @@ -2211,6 +2359,7 @@ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.6" } @@ -2242,6 +2391,7 @@ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "dev": true, "hasInstallScript": true, + "license": "MIT", "optional": true, "os": [ "darwin" @@ -2278,16 +2428,21 @@ } }, "node_modules/get-intrinsic": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz", - "integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", "dev": true, + "license": "MIT", "dependencies": { + "es-errors": "^1.3.0", "function-bind": "^1.1.2", "has-proto": "^1.0.1", "has-symbols": "^1.0.3", "hasown": "^2.0.0" }, + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -2379,12 +2534,13 @@ "dev": true }, "node_modules/has-property-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", - "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", "dev": true, + "license": "MIT", "dependencies": { - "get-intrinsic": "^1.2.2" + "es-define-property": "^1.0.0" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -2446,6 +2602,7 @@ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", "dev": true, + "license": "MIT", "dependencies": { "depd": "2.0.0", "inherits": "2.0.4", @@ -2485,6 +2642,7 @@ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "dev": true, + "license": "MIT", "dependencies": { "safer-buffer": ">= 2.1.2 < 3" }, @@ -2838,10 +2996,11 @@ } }, "node_modules/leaflet": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.7.1.tgz", - "integrity": "sha512-/xwPEBidtg69Q3HlqPdU3DnrXQOvQU/CCHA1tcDQVzOwm91YMYaILjNp7L4Eaw5Z4sOYdbBz6koWyibppd8Zqw==", - "dev": true + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.9.4.tgz", + "integrity": "sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==", + "dev": true, + "license": "BSD-2-Clause" }, "node_modules/leaflet.markercluster": { "version": "1.5.3", @@ -2904,13 +3063,15 @@ "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", "integrity": "sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/lodash.isequal": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/lodash.once": { "version": "4.1.1", @@ -3140,15 +3301,20 @@ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.6" } }, "node_modules/merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==", - "dev": true + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, "node_modules/merge-stream": { "version": "2.0.0", @@ -3170,6 +3336,7 @@ "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", "dev": true, + "license": "MIT", "bin": { "mime": "cli.js" }, @@ -3245,6 +3412,7 @@ "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -3320,10 +3488,14 @@ } }, "node_modules/object-inspect": { - "version": "1.12.3", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", - "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==", + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz", + "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==", "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -3358,6 +3530,7 @@ "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", "dev": true, + "license": "MIT", "dependencies": { "ee-first": "1.1.1" }, @@ -3421,6 +3594,7 @@ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.8" } @@ -3444,10 +3618,11 @@ } }, "node_modules/path-to-regexp": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==", - "dev": true + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", + "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==", + "dev": true, + "license": "MIT" }, "node_modules/pend": { "version": "1.2.0", @@ -3462,10 +3637,11 @@ "dev": true }, "node_modules/picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", + "integrity": "sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==", + "dev": true, + "license": "ISC" }, "node_modules/pify": { "version": "2.3.0", @@ -3483,9 +3659,9 @@ "dev": true }, "node_modules/postcss": { - "version": "8.4.32", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.32.tgz", - "integrity": "sha512-D/kj5JNu6oo2EIy+XL/26JEDTlIbB8hw85G8StOE6L74RQAVVP5rej6wxCNqyMbR4RkPfqvezVbPw81Ngd6Kcw==", + "version": "8.4.47", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.47.tgz", + "integrity": "sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==", "dev": true, "funding": [ { @@ -3501,10 +3677,11 @@ "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "dependencies": { "nanoid": "^3.3.7", - "picocolors": "^1.0.0", - "source-map-js": "^1.0.2" + "picocolors": "^1.1.0", + "source-map-js": "^1.2.1" }, "engines": { "node": "^10 || ^12 || >=14" @@ -3582,12 +3759,13 @@ } }, "node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", + "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { - "side-channel": "^1.0.4" + "side-channel": "^1.0.6" }, "engines": { "node": ">=0.6" @@ -3617,14 +3795,18 @@ } }, "node_modules/quill-delta": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/quill-delta/-/quill-delta-4.2.2.tgz", - "integrity": "sha512-qjbn82b/yJzOjstBgkhtBjN2TNK+ZHP/BgUQO+j6bRhWQQdmj2lH6hXG7+nwwLF41Xgn//7/83lxs9n2BkTtTg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/quill-delta/-/quill-delta-5.1.0.tgz", + "integrity": "sha512-X74oCeRI4/p0ucjb5Ma8adTXd9Scumz367kkMK5V/IatcX6A0vlgLgKbzXWy5nZmCGeNJm2oQX0d2Eqj+ZIlCA==", "dev": true, + "license": "MIT", "dependencies": { - "fast-diff": "1.2.0", + "fast-diff": "^1.3.0", "lodash.clonedeep": "^4.5.0", "lodash.isequal": "^4.5.0" + }, + "engines": { + "node": ">= 12.0.0" } }, "node_modules/quill-delta-to-markdown": { @@ -3664,10 +3846,27 @@ "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.6" } }, + "node_modules/raw-body": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", + "dev": true, + "license": "MIT", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/rdf-canonize": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/rdf-canonize/-/rdf-canonize-3.4.0.tgz", @@ -3753,10 +3952,11 @@ } }, "node_modules/rollup": { - "version": "4.9.6", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.9.6.tgz", - "integrity": "sha512-05lzkCS2uASX0CiLFybYfVkwNbKZG5NFQ6Go0VWyogFTXXbR039UVsegViTntkk4OglHBdF54ccApXRRuXRbsg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.22.4.tgz", + "integrity": "sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A==", "dev": true, + "license": "MIT", "dependencies": { "@types/estree": "1.0.5" }, @@ -3768,19 +3968,22 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.9.6", - "@rollup/rollup-android-arm64": "4.9.6", - "@rollup/rollup-darwin-arm64": "4.9.6", - "@rollup/rollup-darwin-x64": "4.9.6", - "@rollup/rollup-linux-arm-gnueabihf": "4.9.6", - "@rollup/rollup-linux-arm64-gnu": "4.9.6", - "@rollup/rollup-linux-arm64-musl": "4.9.6", - "@rollup/rollup-linux-riscv64-gnu": "4.9.6", - "@rollup/rollup-linux-x64-gnu": "4.9.6", - "@rollup/rollup-linux-x64-musl": "4.9.6", - "@rollup/rollup-win32-arm64-msvc": "4.9.6", - "@rollup/rollup-win32-ia32-msvc": "4.9.6", - "@rollup/rollup-win32-x64-msvc": "4.9.6", + "@rollup/rollup-android-arm-eabi": "4.22.4", + "@rollup/rollup-android-arm64": "4.22.4", + "@rollup/rollup-darwin-arm64": "4.22.4", + "@rollup/rollup-darwin-x64": "4.22.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.22.4", + "@rollup/rollup-linux-arm-musleabihf": "4.22.4", + "@rollup/rollup-linux-arm64-gnu": "4.22.4", + "@rollup/rollup-linux-arm64-musl": "4.22.4", + "@rollup/rollup-linux-powerpc64le-gnu": "4.22.4", + "@rollup/rollup-linux-riscv64-gnu": "4.22.4", + "@rollup/rollup-linux-s390x-gnu": "4.22.4", + "@rollup/rollup-linux-x64-gnu": "4.22.4", + "@rollup/rollup-linux-x64-musl": "4.22.4", + "@rollup/rollup-win32-arm64-msvc": "4.22.4", + "@rollup/rollup-win32-ia32-msvc": "4.22.4", + "@rollup/rollup-win32-x64-msvc": "4.22.4", "fsevents": "~2.3.2" } }, @@ -3820,13 +4023,11 @@ "dev": true }, "node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, + "license": "ISC", "bin": { "semver": "bin/semver.js" }, @@ -3835,10 +4036,11 @@ } }, "node_modules/send": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", - "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", + "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", "dev": true, + "license": "MIT", "dependencies": { "debug": "2.6.9", "depd": "2.0.0", @@ -3863,6 +4065,7 @@ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, + "license": "MIT", "dependencies": { "ms": "2.0.0" } @@ -3871,40 +4074,55 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "dev": true + "dev": true, + "license": "MIT" + }, + "node_modules/send/node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8" + } }, "node_modules/send/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/serve-static": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", - "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", + "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", "dev": true, + "license": "MIT", "dependencies": { - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.18.0" + "send": "0.19.0" }, "engines": { "node": ">= 0.8.0" } }, "node_modules/set-function-length": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.0.tgz", - "integrity": "sha512-4DBHDoyHlM1IRPGYcoxexgh67y4ueR53FKV1yyxwFMY7aCqcN/38M1+SwZ/qJQ8iLv7+ck385ot4CcisOAPT9w==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", "dev": true, + "license": "MIT", "dependencies": { - "define-data-property": "^1.1.1", + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.2", + "get-intrinsic": "^1.2.4", "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.1" + "has-property-descriptors": "^1.0.2" }, "engines": { "node": ">= 0.4" @@ -3920,7 +4138,8 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/shebang-command": { "version": "2.0.0", @@ -3944,14 +4163,19 @@ } }, "node_modules/side-channel": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", - "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", + "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", "dev": true, + "license": "MIT", "dependencies": { - "call-bind": "^1.0.0", - "get-intrinsic": "^1.0.2", - "object-inspect": "^1.9.0" + "call-bind": "^1.0.7", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.4", + "object-inspect": "^1.13.1" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -4031,10 +4255,11 @@ } }, "node_modules/source-map-js": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", - "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", "dev": true, + "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" } @@ -4081,6 +4306,7 @@ "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.8" } @@ -4183,6 +4409,7 @@ "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.6" } @@ -4285,6 +4512,7 @@ "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", "dev": true, + "license": "MIT", "dependencies": { "media-typer": "0.3.0", "mime-types": "~2.1.24" @@ -4313,10 +4541,11 @@ "dev": true }, "node_modules/undici": { - "version": "5.28.2", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.2.tgz", - "integrity": "sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w==", + "version": "5.28.4", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz", + "integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==", "dev": true, + "license": "MIT", "dependencies": { "@fastify/busboy": "^2.0.0" }, @@ -4350,6 +4579,7 @@ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.8" } @@ -4420,14 +4650,15 @@ "dev": true }, "node_modules/vite": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.12.tgz", - "integrity": "sha512-4hsnEkG3q0N4Tzf1+t6NdN9dg/L3BM+q8SWgbSPnJvrgH2kgdyzfVJwbR1ic69/4uMJJ/3dqDZZE5/WwqW8U1w==", + "version": "5.4.8", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.8.tgz", + "integrity": "sha512-FqrItQ4DT1NC4zCUqMB4c4AZORMKIa0m8/URVCZ77OZ/QSNeJ54bU1vrFADbDsuwfIPcgknRkmqakQcgnL4GiQ==", "dev": true, + "license": "MIT", "dependencies": { - "esbuild": "^0.19.3", - "postcss": "^8.4.32", - "rollup": "^4.2.0" + "esbuild": "^0.21.3", + "postcss": "^8.4.43", + "rollup": "^4.20.0" }, "bin": { "vite": "bin/vite.js" @@ -4446,6 +4677,7 @@ "less": "*", "lightningcss": "^1.21.0", "sass": "*", + "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.4.0" @@ -4463,6 +4695,9 @@ "sass": { "optional": true }, + "sass-embedded": { + "optional": true + }, "stylus": { "optional": true }, diff --git a/package.json b/package.json index 990254ab..e4a242a1 100644 --- a/package.json +++ b/package.json @@ -67,35 +67,35 @@ "devDependencies": { "@rckeller/cypress-unfetch": "^1.0.1", "@types/autolinker": "^2.0.0", - "@types/leaflet": "^1.5.21", - "@types/leaflet.markercluster": "^1.4.3", - "@types/markdown-it": "^12.0.1", - "@types/node": "^20.5.0", - "@types/pubsub-js": "^1.8.2", - "@types/quill": "^2.0.4", - "autolinker": "^3.14.2", + "@types/leaflet": "^1.9.12", + "@types/leaflet.markercluster": "^1.5.4", + "@types/markdown-it": "^12.2.3", + "@types/node": "^20.16.7", + "@types/pubsub-js": "^1.8.6", + "@types/quill": "^2.0.14", + "autolinker": "^3.16.2", "cypress": "^13.2.0", "cypress-plugin-tab": "^1.0.5", "delta-markdown-for-quill": "0.0.9", "dialog-polyfill": "^0.5.6", - "express": "^4.17.1", + "express": "^4.21.0", "find-free-port": "^2.0.0", - "fuse.js": "^6.4.6", - "jsonld": "^8.3.1", + "fuse.js": "^6.6.2", + "jsonld": "^8.3.2", "jsonld-context-parser": "^1.3.4", - "leaflet": "1.7.1", + "leaflet": "1.9.4", "leaflet.markercluster": "1.5.3", - "lit-html": "^1.3.0", - "markdown-it": "^12.0.4", + "lit-html": "^1.4.1", + "markdown-it": "^12.3.2", "markdown-it-link-attributes": "4.0.1", - "pubsub-js": "^1.9.2", + "pubsub-js": "^1.9.4", "quill": "^1.3.7", "quill-delta-to-markdown": "^0.6.0", - "semver": "7.5.4", - "slim-select": "^1.27.0", - "tui-calendar": "^1.13.0", + "semver": "7.6.3", + "slim-select": "^1.27.1", + "tui-calendar": "^1.15.3", "typescript": "^4.9.5", - "vite": "^5.0.12" + "vite": "^5.4.8" }, "dependencies": { "cors": "^2.8.5" -- GitLab From 97978a6dd053051ee05608df134239b584fbf7c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Wed, 25 Sep 2024 15:09:14 +0200 Subject: [PATCH 06/66] update: typescript, markdown-it, cypress --- package-lock.json | 254 ++++++++++++++++------------------------------ package.json | 10 +- tsconfig.json | 4 - 3 files changed, 91 insertions(+), 177 deletions(-) diff --git a/package-lock.json b/package-lock.json index 50cfb51d..ddab2fb0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,12 +16,12 @@ "@types/autolinker": "^2.0.0", "@types/leaflet": "^1.9.12", "@types/leaflet.markercluster": "^1.5.4", - "@types/markdown-it": "^12.2.3", - "@types/node": "^20.16.7", + "@types/markdown-it": "^14.1.2", + "@types/node": "^22.7.0", "@types/pubsub-js": "^1.8.6", "@types/quill": "^2.0.14", "autolinker": "^3.16.2", - "cypress": "^13.2.0", + "cypress": "^13.14.2", "cypress-plugin-tab": "^1.0.5", "delta-markdown-for-quill": "0.0.9", "dialog-polyfill": "^0.5.6", @@ -33,7 +33,7 @@ "leaflet": "1.9.4", "leaflet.markercluster": "1.5.3", "lit-html": "^1.4.1", - "markdown-it": "^12.3.2", + "markdown-it": "^14.1.0", "markdown-it-link-attributes": "4.0.1", "pubsub-js": "^1.9.4", "quill": "^1.3.7", @@ -41,7 +41,7 @@ "semver": "7.6.3", "slim-select": "^1.27.1", "tui-calendar": "^1.15.3", - "typescript": "^4.9.5", + "typescript": "^5.6.2", "vite": "^5.4.8" } }, @@ -879,31 +879,34 @@ } }, "node_modules/@types/linkify-it": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-3.0.2.tgz", - "integrity": "sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA==", - "dev": true + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==", + "dev": true, + "license": "MIT" }, "node_modules/@types/markdown-it": { - "version": "12.2.3", - "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-12.2.3.tgz", - "integrity": "sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==", + "version": "14.1.2", + "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-14.1.2.tgz", + "integrity": "sha512-promo4eFwuiW+TfGxhi+0x3czqTYJkG8qB17ZUJiVF10Xm7NLVRSLUsfRTU/6h1e24VvRnXCx+hG7li58lkzog==", "dev": true, + "license": "MIT", "dependencies": { - "@types/linkify-it": "*", - "@types/mdurl": "*" + "@types/linkify-it": "^5", + "@types/mdurl": "^2" } }, "node_modules/@types/mdurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-1.0.2.tgz", - "integrity": "sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==", - "dev": true + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg==", + "dev": true, + "license": "MIT" }, "node_modules/@types/node": { - "version": "20.16.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.7.tgz", - "integrity": "sha512-QkDQjAY3gkvJNcZOWwzy3BN34RweT0OQ9zJyvLCU0kSK22dO2QYh/NHGfbEAYylPYzRB1/iXcojS79wOg5gFSw==", + "version": "22.7.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.0.tgz", + "integrity": "sha512-MOdOibwBs6KW1vfqz2uKMlxq5xAfAZ98SZjO8e3XnAbFnTJtAspqhWk7hrdSAs9/Y14ZWMiy7/MxMUzAOadYEw==", "dev": true, "license": "MIT", "dependencies": { @@ -1156,12 +1159,6 @@ "integrity": "sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg==", "dev": true }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true - }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -1245,16 +1242,6 @@ "dev": true, "license": "MIT" }, - "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, "node_modules/buffer": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", @@ -1477,12 +1464,6 @@ "node": "*" } }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true - }, "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -1554,21 +1535,21 @@ "dev": true }, "node_modules/cypress": { - "version": "13.5.1", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.5.1.tgz", - "integrity": "sha512-yqLViT0D/lPI8Kkm7ciF/x/DCK/H/DnogdGyiTnQgX4OVR2aM30PtK+kvklTOD1u3TuItiD9wUQAF8EYWtyZug==", + "version": "13.14.2", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.14.2.tgz", + "integrity": "sha512-lsiQrN17vHMB2fnvxIrKLAjOr9bPwsNbPZNrWf99s4u+DVmCY6U+w7O3GGG9FvP4EUVYaDu+guWeNLiUzBrqvA==", "dev": true, "hasInstallScript": true, + "license": "MIT", "dependencies": { - "@cypress/request": "^3.0.0", + "@cypress/request": "^3.0.1", "@cypress/xvfb": "^1.2.4", - "@types/node": "^18.17.5", "@types/sinonjs__fake-timers": "8.1.1", "@types/sizzle": "^2.3.2", "arch": "^2.2.0", "blob-util": "^2.0.2", "bluebird": "^3.7.2", - "buffer": "^5.6.0", + "buffer": "^5.7.1", "cachedir": "^2.3.0", "chalk": "^4.1.0", "check-more-types": "^2.24.0", @@ -1586,7 +1567,7 @@ "figures": "^3.2.0", "fs-extra": "^9.1.0", "getos": "^3.2.1", - "is-ci": "^3.0.0", + "is-ci": "^3.0.1", "is-installed-globally": "~0.4.0", "lazy-ass": "^1.6.0", "listr2": "^3.8.3", @@ -1600,7 +1581,7 @@ "request-progress": "^3.0.0", "semver": "^7.5.3", "supports-color": "^8.1.1", - "tmp": "~0.2.1", + "tmp": "~0.2.3", "untildify": "^4.0.0", "yauzl": "^2.10.0" }, @@ -1620,15 +1601,6 @@ "ally.js": "^1.4.1" } }, - "node_modules/cypress/node_modules/@types/node": { - "version": "18.18.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.11.tgz", - "integrity": "sha512-c1vku6qnTeujJneYH94/4aq73XrVcsJe35UPyAsSok1ijiKrkRzK+AxQPSpNMUnC03roWBBwJx/9I8V7lQoxmA==", - "dev": true, - "dependencies": { - "undici-types": "~5.26.4" - } - }, "node_modules/cypress/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -2379,12 +2351,6 @@ "node": ">=10" } }, - "node_modules/fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", - "dev": true - }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -2480,26 +2446,6 @@ "assert-plus": "^1.0.0" } }, - "node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "dev": true, - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/global-dirs": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-3.0.1.tgz", @@ -2679,16 +2625,6 @@ "node": ">=8" } }, - "node_modules/inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", - "dev": true, - "dependencies": { - "once": "^1.3.0", - "wrappy": "1" - } - }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", @@ -3012,12 +2948,13 @@ } }, "node_modules/linkify-it": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.3.tgz", - "integrity": "sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", "dev": true, + "license": "MIT", "dependencies": { - "uc.micro": "^1.0.1" + "uc.micro": "^2.0.0" } }, "node_modules/listr2": { @@ -3260,19 +3197,21 @@ } }, "node_modules/markdown-it": { - "version": "12.3.2", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-12.3.2.tgz", - "integrity": "sha512-TchMembfxfNVpHkbtriWltGWc+m3xszaRD0CZup7GFFhzIgQqxIfn3eGj1yZpfuflzPvfkt611B2Q/Bsk1YnGg==", + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", + "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", "dev": true, + "license": "MIT", "dependencies": { "argparse": "^2.0.1", - "entities": "~2.1.0", - "linkify-it": "^3.0.1", - "mdurl": "^1.0.1", - "uc.micro": "^1.0.5" + "entities": "^4.4.0", + "linkify-it": "^5.0.0", + "mdurl": "^2.0.0", + "punycode.js": "^2.3.1", + "uc.micro": "^2.1.0" }, "bin": { - "markdown-it": "bin/markdown-it.js" + "markdown-it": "bin/markdown-it.mjs" } }, "node_modules/markdown-it-link-attributes": { @@ -3282,14 +3221,25 @@ "dev": true }, "node_modules/markdown-it/node_modules/entities": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz", - "integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, "funding": { "url": "https://github.com/fb55/entities?sponsor=1" } }, + "node_modules/markdown-it/node_modules/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "dev": true, + "license": "MIT" + }, "node_modules/mdurl": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", @@ -3374,18 +3324,6 @@ "node": ">=6" } }, - "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/minimist": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", @@ -3599,15 +3537,6 @@ "node": ">= 0.8" } }, - "node_modules/path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", @@ -3758,6 +3687,16 @@ "node": ">=6" } }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/qs": { "version": "6.13.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", @@ -3936,21 +3875,6 @@ "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==", "dev": true }, - "node_modules/rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/rollup": { "version": "4.22.4", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.22.4.tgz", @@ -4393,15 +4317,13 @@ "dev": true }, "node_modules/tmp": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", - "integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==", + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz", + "integrity": "sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==", "dev": true, - "dependencies": { - "rimraf": "^3.0.0" - }, + "license": "MIT", "engines": { - "node": ">=8.17.0" + "node": ">=14.14" } }, "node_modules/toidentifier": { @@ -4522,23 +4444,25 @@ } }, "node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", + "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, "node_modules/uc.micro": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", - "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", - "dev": true + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", + "dev": true, + "license": "MIT" }, "node_modules/undici": { "version": "5.28.4", @@ -4553,12 +4477,6 @@ "node": ">=14.0" } }, - "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", - "dev": true - }, "node_modules/unfetch": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/unfetch/-/unfetch-4.2.0.tgz", diff --git a/package.json b/package.json index e4a242a1..edab7b38 100644 --- a/package.json +++ b/package.json @@ -69,12 +69,12 @@ "@types/autolinker": "^2.0.0", "@types/leaflet": "^1.9.12", "@types/leaflet.markercluster": "^1.5.4", - "@types/markdown-it": "^12.2.3", - "@types/node": "^20.16.7", + "@types/markdown-it": "^14.1.2", + "@types/node": "^22.7.0", "@types/pubsub-js": "^1.8.6", "@types/quill": "^2.0.14", "autolinker": "^3.16.2", - "cypress": "^13.2.0", + "cypress": "^13.14.2", "cypress-plugin-tab": "^1.0.5", "delta-markdown-for-quill": "0.0.9", "dialog-polyfill": "^0.5.6", @@ -86,7 +86,7 @@ "leaflet": "1.9.4", "leaflet.markercluster": "1.5.3", "lit-html": "^1.4.1", - "markdown-it": "^12.3.2", + "markdown-it": "^14.1.0", "markdown-it-link-attributes": "4.0.1", "pubsub-js": "^1.9.4", "quill": "^1.3.7", @@ -94,7 +94,7 @@ "semver": "7.6.3", "slim-select": "^1.27.1", "tui-calendar": "^1.15.3", - "typescript": "^4.9.5", + "typescript": "^5.6.2", "vite": "^5.4.8" }, "dependencies": { diff --git a/tsconfig.json b/tsconfig.json index 645ec740..cfe00896 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,11 +12,7 @@ "composite": false, "strict": true, "noImplicitAny": false, - "strictNullChecks": true, - "strictFunctionTypes": true, - "strictPropertyInitialization": true, "noImplicitThis": false, - "alwaysStrict": true, "noUnusedLocals": true, "noUnusedParameters": true, "noImplicitReturns": true, -- GitLab From 5075dc9f3ed7264d5bd8a2a2beaab93e6664b71e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Wed, 25 Sep 2024 15:55:06 +0200 Subject: [PATCH 07/66] update: quill@2 --- package-lock.json | 97 +++++++------------ package.json | 5 +- .../callbackMixins/richtextMixin.ts | 2 +- 3 files changed, 37 insertions(+), 67 deletions(-) diff --git a/package-lock.json b/package-lock.json index ddab2fb0..82faf541 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,8 +19,7 @@ "@types/markdown-it": "^14.1.2", "@types/node": "^22.7.0", "@types/pubsub-js": "^1.8.6", - "@types/quill": "^2.0.14", - "autolinker": "^3.16.2", + "autolinker": "^4.0.0", "cypress": "^13.14.2", "cypress-plugin-tab": "^1.0.5", "delta-markdown-for-quill": "0.0.9", @@ -36,7 +35,7 @@ "markdown-it": "^14.1.0", "markdown-it-link-attributes": "4.0.1", "pubsub-js": "^1.9.4", - "quill": "^1.3.7", + "quill": "^2.0.2", "quill-delta-to-markdown": "^0.6.0", "semver": "7.6.3", "slim-select": "^1.27.1", @@ -927,17 +926,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/quill": { - "version": "2.0.14", - "resolved": "https://registry.npmjs.org/@types/quill/-/quill-2.0.14.tgz", - "integrity": "sha512-zvoXCRnc2Dl8g+7/9VSAmRWPN6oH+MVhTPizmCR+GJCITplZ5VRVzMs4+a/nOE3yzNwEZqylJJrMB07bwbM1/g==", - "dev": true, - "license": "MIT", - "dependencies": { - "parchment": "^1.1.2", - "quill-delta": "^5.1.0" - } - }, "node_modules/@types/sinonjs__fake-timers": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.1.tgz", @@ -1136,10 +1124,11 @@ } }, "node_modules/autolinker": { - "version": "3.16.2", - "resolved": "https://registry.npmjs.org/autolinker/-/autolinker-3.16.2.tgz", - "integrity": "sha512-JiYl7j2Z19F9NdTmirENSUUIIL/9MytEWtmzhfmsKPCp9E+G35Y0UNCMoM9tFigxT59qSc8Ml2dlZXOCVTYwuA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/autolinker/-/autolinker-4.0.0.tgz", + "integrity": "sha512-fl5Kh6BmEEZx+IWBfEirnRUU5+cOiV0OK7PEt0RBKvJMJ8GaRseIOeDU3FKf4j3CE5HVefcjHmhYPOcaVt0bZw==", "dev": true, + "license": "MIT", "dependencies": { "tslib": "^2.3.0" } @@ -1410,15 +1399,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/clone": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", - "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", - "dev": true, - "engines": { - "node": ">=0.8" - } - }, "node_modules/colorette": { "version": "2.0.20", "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz", @@ -2051,10 +2031,11 @@ "dev": true }, "node_modules/eventemitter3": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-2.0.3.tgz", - "integrity": "sha512-jLN68Dx5kyFHaePoXWPsCGW5qdyZQtLYHkxkg02/Mz6g0kYpDx4FyP6XfArhQdlOC4b8Mv+EMxPo/8La7Tzghg==", - "dev": true + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", + "dev": true, + "license": "MIT" }, "node_modules/execa": { "version": "4.1.0", @@ -2996,6 +2977,13 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, + "node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==", + "dev": true, + "license": "MIT" + }, "node_modules/lodash.clonedeep": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", @@ -3521,12 +3509,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/parchment": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/parchment/-/parchment-1.1.4.tgz", - "integrity": "sha512-J5FBQt/pM2inLzg4hEWmzQx/8h8D0CiDxaG3vyp9rKrQRSDgBlhjdP5jQGgosEajXPSQouXGHOmVdgo7QmJuOg==", - "dev": true - }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -3720,17 +3702,19 @@ "dev": true }, "node_modules/quill": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/quill/-/quill-1.3.7.tgz", - "integrity": "sha512-hG/DVzh/TiknWtE6QmWAF/pxoZKYxfe3J/d/+ShUWkDvvkZQVTPeVmUJVu1uE6DDooC4fWTiCLh84ul89oNz5g==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/quill/-/quill-2.0.2.tgz", + "integrity": "sha512-QfazNrhMakEdRG57IoYFwffUIr04LWJxbS/ZkidRFXYCQt63c1gK6Z7IHUXMx/Vh25WgPBU42oBaNzQ0K1R/xw==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { - "clone": "^2.1.1", - "deep-equal": "^1.0.1", - "eventemitter3": "^2.0.3", - "extend": "^3.0.2", - "parchment": "^1.1.4", - "quill-delta": "^3.6.2" + "eventemitter3": "^5.0.1", + "lodash-es": "^4.17.21", + "parchment": "^3.0.0", + "quill-delta": "^5.1.0" + }, + "engines": { + "npm": ">=8.2.3" } }, "node_modules/quill-delta": { @@ -3760,25 +3744,12 @@ "node": ">=6.4.0" } }, - "node_modules/quill/node_modules/fast-diff": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.1.2.tgz", - "integrity": "sha512-KaJUt+M9t1qaIteSvjc6P3RbMdXsNhK61GRftR6SNxqmhthcd9MGIi4T+o0jD8LUSpSnSKXE20nLtJ3fOHxQig==", - "dev": true - }, - "node_modules/quill/node_modules/quill-delta": { - "version": "3.6.3", - "resolved": "https://registry.npmjs.org/quill-delta/-/quill-delta-3.6.3.tgz", - "integrity": "sha512-wdIGBlcX13tCHOXGMVnnTVFtGRLoP0imqxM696fIPwIf5ODIYUHIvHbZcyvGlZFiFhK5XzDC2lpjbxRhnM05Tg==", + "node_modules/quill/node_modules/parchment": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/parchment/-/parchment-3.0.0.tgz", + "integrity": "sha512-HUrJFQ/StvgmXRcQ1ftY6VEZUq3jA2t9ncFN4F84J/vN0/FPpQF+8FKXb3l6fLces6q0uOHj6NJn+2xvZnxO6A==", "dev": true, - "dependencies": { - "deep-equal": "^1.0.1", - "extend": "^3.0.2", - "fast-diff": "1.1.2" - }, - "engines": { - "node": ">=0.10" - } + "license": "BSD-3-Clause" }, "node_modules/range-parser": { "version": "1.2.1", diff --git a/package.json b/package.json index edab7b38..b3ffbf43 100644 --- a/package.json +++ b/package.json @@ -72,8 +72,7 @@ "@types/markdown-it": "^14.1.2", "@types/node": "^22.7.0", "@types/pubsub-js": "^1.8.6", - "@types/quill": "^2.0.14", - "autolinker": "^3.16.2", + "autolinker": "^4.0.0", "cypress": "^13.14.2", "cypress-plugin-tab": "^1.0.5", "delta-markdown-for-quill": "0.0.9", @@ -89,7 +88,7 @@ "markdown-it": "^14.1.0", "markdown-it-link-attributes": "4.0.1", "pubsub-js": "^1.9.4", - "quill": "^1.3.7", + "quill": "^2.0.2", "quill-delta-to-markdown": "^0.6.0", "semver": "7.6.3", "slim-select": "^1.27.1", diff --git a/src/new-widgets/callbackMixins/richtextMixin.ts b/src/new-widgets/callbackMixins/richtextMixin.ts index 63fecf69..778185bf 100644 --- a/src/new-widgets/callbackMixins/richtextMixin.ts +++ b/src/new-widgets/callbackMixins/richtextMixin.ts @@ -28,7 +28,7 @@ const RichtextMixin = { ['link'], ['clean'] ]; - const richtext = this.element.querySelector('[data-richtext]'); + const richtext = this.element.querySelector('[data-richtext]') as HTMLElement; this.quill = new Quill( richtext, { -- GitLab From 8ccdd87e15d1c0c4240f29404d4d607b4d443dac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Wed, 25 Sep 2024 16:27:30 +0200 Subject: [PATCH 08/66] update: fuse.js --- package-lock.json | 17 +++++++++-------- package.json | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 82faf541..ab528ac5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@types/leaflet": "^1.9.12", "@types/leaflet.markercluster": "^1.5.4", "@types/markdown-it": "^14.1.2", - "@types/node": "^22.7.0", + "@types/node": "^22.7.1", "@types/pubsub-js": "^1.8.6", "autolinker": "^4.0.0", "cypress": "^13.14.2", @@ -26,7 +26,7 @@ "dialog-polyfill": "^0.5.6", "express": "^4.21.0", "find-free-port": "^2.0.0", - "fuse.js": "^6.6.2", + "fuse.js": "^7.0.0", "jsonld": "^8.3.2", "jsonld-context-parser": "^1.3.4", "leaflet": "1.9.4", @@ -903,9 +903,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.7.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.0.tgz", - "integrity": "sha512-MOdOibwBs6KW1vfqz2uKMlxq5xAfAZ98SZjO8e3XnAbFnTJtAspqhWk7hrdSAs9/Y14ZWMiy7/MxMUzAOadYEw==", + "version": "22.7.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.1.tgz", + "integrity": "sha512-adOMRLVmleuWs/5V/w5/l7o0chDK/az+5ncCsIapTKogsu/3MVWvSgP58qVTXi5IwpfGt8pMobNq9rOWtJyu5Q==", "dev": true, "license": "MIT", "dependencies": { @@ -2366,10 +2366,11 @@ } }, "node_modules/fuse.js": { - "version": "6.6.2", - "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-6.6.2.tgz", - "integrity": "sha512-cJaJkxCCxC8qIIcPBF9yGxY0W/tVZS3uEISDxhYIdtk8OL93pe+6Zj7LjCqVV4dzbqcriOZ+kQ/NE4RXZHsIGA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-7.0.0.tgz", + "integrity": "sha512-14F4hBIxqKvD4Zz/XjDc3y94mNZN6pRv3U13Udo0lNLCWRBUsrMv2xwcF/y/Z5sV6+FQW+/ow68cHpm4sunt8Q==", "dev": true, + "license": "Apache-2.0", "engines": { "node": ">=10" } diff --git a/package.json b/package.json index b3ffbf43..7f62b6cf 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "@types/leaflet": "^1.9.12", "@types/leaflet.markercluster": "^1.5.4", "@types/markdown-it": "^14.1.2", - "@types/node": "^22.7.0", + "@types/node": "^22.7.1", "@types/pubsub-js": "^1.8.6", "autolinker": "^4.0.0", "cypress": "^13.14.2", @@ -79,7 +79,7 @@ "dialog-polyfill": "^0.5.6", "express": "^4.21.0", "find-free-port": "^2.0.0", - "fuse.js": "^6.6.2", + "fuse.js": "^7.0.0", "jsonld": "^8.3.2", "jsonld-context-parser": "^1.3.4", "leaflet": "1.9.4", -- GitLab From 0113197d34b596981a61b749bf5f844cc1a898f5 Mon Sep 17 00:00:00 2001 From: Benoit Alessandroni <benoit@startinblox.com> Date: Tue, 1 Oct 2024 10:42:42 +0200 Subject: [PATCH 09/66] feature: 851 improve logging and debugging experience --- package-lock.json | 15 +- package.json | 3 +- src/components/solid-ac-checker.ts | 45 ++-- src/components/solid-delete.ts | 20 +- src/components/solid-display.ts | 12 +- src/components/solid-form-search.ts | 45 ++-- src/components/solid-form.ts | 53 ++--- src/components/solid-map.ts | 11 +- src/components/solid-member-delete.ts | 6 +- src/components/solid-membership.ts | 55 ++--- src/components/solid-table.ts | 8 +- src/libs/Component.ts | 3 + src/libs/PostProcessorRegistry.ts | 81 ++++++++ src/libs/interfaces.ts | 3 + src/logger.ts | 192 ++++++++++++++++++ src/mixins/counterMixin.ts | 6 +- src/mixins/federationMixin.ts | 7 +- src/mixins/filterMixin.ts | 5 +- src/mixins/grouperMixin.ts | 7 +- src/mixins/highlighterMixin.ts | 6 +- src/mixins/listMixin.ts | 32 +-- src/mixins/paginateMixin.ts | 5 +- src/mixins/requiredMixin.ts | 6 +- src/mixins/sorterMixin.ts | 6 +- src/new-widgets/baseWidgetMixin.ts | 38 ++-- .../callbackMixins/autocompletionMixin.ts | 5 +- .../callbackMixins/richtextMixin.ts | 5 +- .../templateAdditionMixins/addableMixin.ts | 5 +- .../templateAdditionMixins/labelLastMixin.ts | 7 +- .../templateAdditionMixins/labelMixin.ts | 7 +- .../templatesDependencies/editableMixin.ts | 7 +- .../multipleFormMixin.ts | 7 +- .../multipleselectFormMixin.ts | 5 +- .../templatesDependencies/rangeMixin.ts | 13 +- .../autolinkMixin.ts | 5 +- .../valueTransformationMixins/dateMixin.ts | 6 +- .../dateTimeMixin.ts | 6 +- .../markdownMixin.ts | 7 +- .../multilineMixin.ts | 7 +- .../valueTransformationMixins/oembedMixin.ts | 7 +- 40 files changed, 561 insertions(+), 208 deletions(-) create mode 100644 src/libs/PostProcessorRegistry.ts create mode 100644 src/logger.ts diff --git a/package-lock.json b/package-lock.json index ab528ac5..54ef83a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,8 @@ "version": "0.0.0", "license": "MIT", "dependencies": { - "cors": "^2.8.5" + "cors": "^2.8.5", + "loglevel": "^1.9.1" }, "devDependencies": { "@rckeller/cypress-unfetch": "^1.0.1", @@ -3173,6 +3174,18 @@ "node": ">=8" } }, + "node_modules/loglevel": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.9.1.tgz", + "integrity": "sha512-hP3I3kCrDIMuRwAwHltphhDM1r8i55H33GgqjXbrisuJhF4kRhW1dNuxsRklp4bXl8DSdLaNLuiL4A/LWRfxvg==", + "engines": { + "node": ">= 0.6.0" + }, + "funding": { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/loglevel" + } + }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", diff --git a/package.json b/package.json index 7f62b6cf..052d3ca3 100644 --- a/package.json +++ b/package.json @@ -97,6 +97,7 @@ "vite": "^5.4.8" }, "dependencies": { - "cors": "^2.8.5" + "cors": "^2.8.5", + "loglevel": "^1.9.1" } } diff --git a/src/components/solid-ac-checker.ts b/src/components/solid-ac-checker.ts index 4f5d1034..fdadfe8d 100644 --- a/src/components/solid-ac-checker.ts +++ b/src/components/solid-ac-checker.ts @@ -1,6 +1,7 @@ import JSONLDContextParser from 'jsonld-context-parser'; import { Sib } from '../libs/Sib'; import { StoreMixin } from '../mixins/storeMixin'; +import { trackRenderAsync } from '../logger'; export const SolidAcChecker = { name: 'solid-ac-checker', @@ -15,27 +16,29 @@ export const SolidAcChecker = { default: '', } }, - - async populate(): Promise<void> { - if (!this.resource) return; - let displayElement: boolean; - const ContextParser = JSONLDContextParser.ContextParser; - const permissions = await this.resource.permissions; - if (this.permission) { // User has permission of ... - displayElement = permissions.some((p:any) => { - return ContextParser.expandTerm(p, this.context, true) === this.permission; - }); - } else if (this.noPermission) { // User has no permission of ... - displayElement = permissions.every((p:any) => { - return ContextParser.expandTerm(p, this.context, true) !== this.noPermission; - }); - } else { // No parameter provided - console.warn('solid-ac-checker: you should define at least one of "permission" or "no-permission" attribute.'); - return; - } - - if (displayElement) this.element.removeAttribute('hidden'); - }, + populate: trackRenderAsync( + async function(): Promise<void> { + if (!this.resource) return; + let displayElement: boolean; + const ContextParser = JSONLDContextParser.ContextParser; + const permissions = await this.resource.permissions; + if (this.permission) { // User has permission of ... + displayElement = permissions.some((p:any) => { + return ContextParser.expandTerm(p, this.context, true) === this.permission; + }); + } else if (this.noPermission) { // User has no permission of ... + displayElement = permissions.every((p:any) => { + return ContextParser.expandTerm(p, this.context, true) !== this.noPermission; + }); + } else { // No parameter provided + console.warn('solid-ac-checker: you should define at least one of "permission" or "no-permission" attribute.'); + return; + } + + if (displayElement) this.element.removeAttribute('hidden'); + }, + "SolidAcChecker:populate" + ), empty(): void { this.element.setAttribute('hidden', ''); } diff --git a/src/components/solid-delete.ts b/src/components/solid-delete.ts index b6797de2..e755fb92 100644 --- a/src/components/solid-delete.ts +++ b/src/components/solid-delete.ts @@ -6,6 +6,7 @@ import { AttributeBinderMixin } from '../mixins/attributeBinderMixin'; import { html, render } from 'lit-html'; import { ContextMixin } from '../mixins/contextMixin'; +import { trackRenderAsync } from '../logger'; export const SolidDelete = { name: 'solid-delete', @@ -61,14 +62,17 @@ export const SolidDelete = { update() { this.render(); }, - async render(): Promise<void> { - await this.replaceAttributesData(false); - const button = html` - <button @click=${this.delete.bind(this)}>${this.dataLabel || this.t("solid-delete.button")}</button> - ${this.getModalDialog()} - `; - render(button, this.element); - } + render: trackRenderAsync( + async function(): Promise<void> { + await this.replaceAttributesData(false); + const button = html` + <button @click=${this.delete.bind(this)}>${this.dataLabel || this.t("solid-delete.button")}</button> + ${this.getModalDialog()} + `; + render(button, this.element); + }, + "SolidDelete:render" + ) }; Sib.register(SolidDelete); \ No newline at end of file diff --git a/src/components/solid-display.ts b/src/components/solid-display.ts index df4f833f..21f89d82 100644 --- a/src/components/solid-display.ts +++ b/src/components/solid-display.ts @@ -15,6 +15,8 @@ import { spread } from '../libs/lit-helpers'; import { html, render } from 'lit-html'; import { ifDefined } from 'lit-html/directives/if-defined'; +import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import { trackRenderAsync } from '../logger'; export const SolidDisplay = { name: 'solid-display', @@ -141,9 +143,8 @@ export const SolidDisplay = { * @param div * @param context */ - async renderDOM( - resources: object[], - listPostProcessors: Function[], + renderDOM: trackRenderAsync(async function( resources: object[], + listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string, ) { @@ -151,8 +152,9 @@ export const SolidDisplay = { // and create a child template for each resource const template = html`${resources.map(r => r ? this.getChildTemplate(r['@id'], attributes) : null)}`; render(template, div); - + const nextProcessor = listPostProcessors.shift(); + if (nextProcessor) await nextProcessor( resources, @@ -160,7 +162,7 @@ export const SolidDisplay = { div, context ); - }, + }, "SolidDisplay:renderDom"), /** * Get attributes to dispatch to children from current element diff --git a/src/components/solid-form-search.ts b/src/components/solid-form-search.ts index 75f1bceb..66433c04 100644 --- a/src/components/solid-form-search.ts +++ b/src/components/solid-form-search.ts @@ -9,6 +9,7 @@ import { html, render } from 'lit-html'; import { ifDefined } from 'lit-html/directives/if-defined'; import { uniqID } from '../libs/helpers'; import type { SearchQuery, FilterEventOptions } from '../libs/interfaces'; +import { trackRenderAsync } from '../logger'; export const SolidFormSearch = { name: 'solid-form-search', @@ -200,26 +201,30 @@ export const SolidFormSearch = { this.inputChange(input); }, this.debounce); }, - async populate(): Promise<void> { - await this.replaceAttributesData(); - if(this.submitButton == null) { - this.element.addEventListener('input', (e: Event) => this.debounceInput(e.target)); - } else { - this.element.addEventListener('submit', (e: Event) => { - e.preventDefault(); - this.inputChange(e.target); - }); - } - const fields = await this.getFields(); - const widgetTemplates = await Promise.all(fields.map((field: string) => this.createWidgetTemplate(field))); - const template = html` - <form> - ${widgetTemplates} - ${this.submitButton == null ? '' : this.getSubmitTemplate()} - </form> - `; - render(template, this.element); - } + populate: trackRenderAsync( + async function(): Promise<void> { + await this.replaceAttributesData(); + if(this.submitButton == null) { + this.element.addEventListener('input', (e: Event) => this.debounceInput(e.target)); + } else { + this.element.addEventListener('submit', (e: Event) => { + e.preventDefault(); + this.inputChange(e.target); + }); + } + const fields = await this.getFields(); + const widgetTemplates = await Promise.all(fields.map((field: string) => this.createWidgetTemplate(field))); + const template = html` + <form> + ${widgetTemplates} + ${this.submitButton == null ? '' : this.getSubmitTemplate()} + </form> + `; + render(template, this.element); + }, + "SolidFormSearch:populate" + ) + }; Sib.register(SolidFormSearch); \ No newline at end of file diff --git a/src/components/solid-form.ts b/src/components/solid-form.ts index b79e2da7..7e2af66c 100644 --- a/src/components/solid-form.ts +++ b/src/components/solid-form.ts @@ -9,6 +9,7 @@ import type { WidgetInterface } from '../mixins/interfaces'; import { html, render } from 'lit-html'; import { ifDefined } from 'lit-html/directives/if-defined'; +import { trackRenderAsync } from '../logger'; export const SolidForm = { name: 'solid-form', @@ -277,31 +278,35 @@ export const SolidForm = { </div> ` }, - async populate(): Promise<void> { - this.element.oninput = () => this.onInput(); // prevent from firing change multiple times - this.element.onchange = () => this.onChange(); - const fields = await this.getFields(); - const widgetTemplates = await Promise.all(fields.map((field: string) => this.createWidgetTemplate(field))); - const template = html` - <div data-id="error"></div> - ${!this.isNaked ? html` - <form - @submit=${this.onSubmit.bind(this)} - @reset=${this.onReset.bind(this)} - > + populate: trackRenderAsync( + async function(): Promise<void> { + this.element.oninput = () => this.onInput(); // prevent from firing change multiple times + this.element.onchange = () => this.onChange(); + const fields = await this.getFields(); + const widgetTemplates = await Promise.all(fields.map((field: string) => this.createWidgetTemplate(field))); + const template = html` + <div data-id="error"></div> + ${!this.isNaked ? html` + <form + @submit=${this.onSubmit.bind(this)} + @reset=${this.onReset.bind(this)} + > + ${widgetTemplates} + ${!this.isSavingAutomatically ? this.getSubmitTemplate() : ''} + ${this.element.hasAttribute('reset') + ? html`<input type="reset" />` : ''} + </form> + ` : html` ${widgetTemplates} - ${!this.isSavingAutomatically ? this.getSubmitTemplate() : ''} - ${this.element.hasAttribute('reset') - ? html`<input type="reset" />` : ''} - </form> - ` : html` - ${widgetTemplates} - ` - } - ${this.getModalDialog()} - `; - render(template, this.element); - } + ` + } + ${this.getModalDialog()} + `; + render(template, this.element); + }, + "SolidForm:populate" + ) + }; Sib.register(SolidForm); \ No newline at end of file diff --git a/src/components/solid-map.ts b/src/components/solid-map.ts index 9c80693f..3c3d0a06 100644 --- a/src/components/solid-map.ts +++ b/src/components/solid-map.ts @@ -17,6 +17,8 @@ import 'https://cdn.skypack.dev/leaflet.markercluster'; // TODO : revert to "lea import { html, render } from 'lit-html'; import { ifDefined } from 'lit-html/directives/if-defined'; +import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import { trackRenderAsync } from '../logger'; export const SolidMap = { name: 'solid-map', @@ -216,14 +218,15 @@ export const SolidMap = { * @param div * @param context */ - async renderDOM(resources: object[], listPostProcessors: Function[], div: HTMLElement, context: string) { + renderDOM: trackRenderAsync( + async function(resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string) { const groupClass = div.dataset.groupClass || ''; // get the group class from the useless div element await Promise.all(resources.map(resource => this.appendChildElt(resource['@id'], groupClass))) this.planReset(); - const nextProcessor = listPostProcessors.shift(); - if(nextProcessor) await nextProcessor(resources, listPostProcessors, div, context); - } + const nextProcessor = listPostProcessors.shift(); + if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context); + }, "SolidMap:renderDOM" ) }; Sib.register(SolidMap); \ No newline at end of file diff --git a/src/components/solid-member-delete.ts b/src/components/solid-member-delete.ts index 9e90c1ba..eaf41c56 100644 --- a/src/components/solid-member-delete.ts +++ b/src/components/solid-member-delete.ts @@ -6,6 +6,7 @@ import { ifDefined } from 'lit-html/directives/if-defined'; import { html, render } from 'lit-html'; import { ContextMixin } from '../mixins/contextMixin'; +import { trackRenderAsync } from '../logger'; export const SolidMemberDelete = { name: 'solid-member-delete', @@ -122,7 +123,8 @@ export const SolidMemberDelete = { update() { this.render(); }, - async render(): Promise<void> { + render: trackRenderAsync( + async function(): Promise<void> { // await this.replaceAttributesData(false); await this.populate(); let button = html`` @@ -145,7 +147,7 @@ export const SolidMemberDelete = { `; } render(button, this.element); - } + }, "SolidMemberDelete:render") }; Sib.register(SolidMemberDelete); \ No newline at end of file diff --git a/src/components/solid-membership.ts b/src/components/solid-membership.ts index 0e898e90..338556b2 100644 --- a/src/components/solid-membership.ts +++ b/src/components/solid-membership.ts @@ -6,6 +6,7 @@ import { ValidationMixin } from '../mixins/validationMixin'; import { html, render } from 'lit-html'; import { ContextMixin } from '../mixins/contextMixin'; import { ifDefined } from 'lit-html/directives/if-defined'; +import { trackRenderAsync } from '../logger'; export const SolidMembership = { name: 'solid-membership', @@ -149,32 +150,34 @@ export const SolidMembership = { update() { this.render(); }, - async render(): Promise<void> { - await this.populate(); - let button = html``; - if (this.isMember) { - button = html` - <solid-ac-checker data-src="${this.dataSrc}" - permission="acl:Read" - class=${ifDefined(`${this.classSubmitButton ? 'leave ' + this.classSubmitButton: 'leave'}`)} - > - <button @click=${this.changeMembership.bind(this)}>${this.dataLeaveLabel || this.t("solid-leave-group.button")}</button> - ${this.getModalDialog()} - </solid-ac-checker> - `; - } else { - button = html` - <solid-ac-checker data-src="${this.dataSrc}" - permission="acl:Read" - class=${ifDefined(`${this.classSubmitButton ? 'join ' + this.classSubmitButton: 'join'}`)} - > - <button @click=${this.changeMembership.bind(this)}>${this.dataJoinLabel || this.t("solid-join-group.button")}</button> - ${this.getModalDialog()} - </solid-ac-checker> - `; - } - render(button, this.element); - } + render: trackRenderAsync( + async function(): Promise<void> { + await this.populate(); + let button = html``; + if (this.isMember) { + button = html` + <solid-ac-checker data-src="${this.dataSrc}" + permission="acl:Read" + class=${ifDefined(`${this.classSubmitButton ? 'leave ' + this.classSubmitButton: 'leave'}`)} + > + <button @click=${this.changeMembership.bind(this)}>${this.dataLeaveLabel || this.t("solid-leave-group.button")}</button> + ${this.getModalDialog()} + </solid-ac-checker> + `; + } else { + button = html` + <solid-ac-checker data-src="${this.dataSrc}" + permission="acl:Read" + class=${ifDefined(`${this.classSubmitButton ? 'join ' + this.classSubmitButton: 'join'}`)} + > + <button @click=${this.changeMembership.bind(this)}>${this.dataJoinLabel || this.t("solid-join-group.button")}</button> + ${this.getModalDialog()} + </solid-ac-checker> + `; + } + render(button, this.element); + }, + "SolidMembership:render") }; Sib.register(SolidMembership); \ No newline at end of file diff --git a/src/components/solid-table.ts b/src/components/solid-table.ts index 519733c8..46005d7b 100644 --- a/src/components/solid-table.ts +++ b/src/components/solid-table.ts @@ -16,6 +16,8 @@ import { RequiredMixin } from '../mixins/requiredMixin'; import { html, render } from 'lit-html'; import { until } from 'lit-html/directives/until'; import { spread } from '../libs/lit-helpers'; +import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import { trackRenderAsync } from '../logger'; export const SolidTable = { name: 'solid-table', @@ -195,9 +197,9 @@ export const SolidTable = { * @param div * @param context */ - async renderDOM( + renderDOM: trackRenderAsync(async function( resources: object[], - listPostProcessors: Function[], + listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string, ) { @@ -224,7 +226,7 @@ export const SolidTable = { div, context ); - }, + }, "SolidTable:renderDom"), }; Sib.register(SolidTable); diff --git a/src/libs/Component.ts b/src/libs/Component.ts index e655a190..e22ae00b 100644 --- a/src/libs/Component.ts +++ b/src/libs/Component.ts @@ -1,10 +1,13 @@ +import { Profiler } from "../logger"; import type { ComponentInterface } from "./interfaces.js"; export abstract class Component implements ComponentInterface { public element: HTMLElement; + public profiler: Profiler; constructor(element: HTMLElement) { this.element = element; + this.profiler = new Profiler(); } created() {} diff --git a/src/libs/PostProcessorRegistry.ts b/src/libs/PostProcessorRegistry.ts new file mode 100644 index 00000000..e0f33197 --- /dev/null +++ b/src/libs/PostProcessorRegistry.ts @@ -0,0 +1,81 @@ +export type PostProcessor = { + name: string; + fn: Function; +}; + +export class PostProcessorRegistry { + private currentPostProcessors: PostProcessor[]; + + constructor(currentPostProcessors: PostProcessor[] = []) { + this.currentPostProcessors = [...currentPostProcessors]; + } + + public attach(callback: Function, callbackName: string): void { + this.currentPostProcessors.push({ name: callbackName, fn: callback }); + } + + public getPostProcessors(): PostProcessor[] { + return this.currentPostProcessors; + } + + public printCurrentCallbacks(): void { + if (this.currentPostProcessors.length === 0) { + console.log('No post-processors registered.'); + } else { + console.log('Registered post-processors:'); + this.currentPostProcessors.forEach(proc => { + console.log(`- ${proc.name}`); + }); + } + } + + public getFormattedCallbacks(): string { + if (this.currentPostProcessors.length === 0) { + return 'No post-processors registered.'; + } else { + let formattedText = 'Registered post-processors:\n'; + this.currentPostProcessors.forEach(proc => { + formattedText += `- ${proc.name}\n`; + }); + return formattedText.trim(); + } + } + + static printFormattedCallbacks(currentPostProcessors: PostProcessor[]): string { + if (currentPostProcessors.length === 0) { + return 'No post-processors registered.'; + } else { + let formattedText = 'Registered post-processors:\n'; + currentPostProcessors.forEach(proc => { + formattedText += `- ${proc.name}\n`; + }); + return formattedText.trim(); + } + } + + public whichCallbackExecutedNext(): string { + if (this.currentPostProcessors.length === 0) { + return 'No post-processors registered.'; + } else { + return `Next post-processor to be executed is: ${this.currentPostProcessors[0].name}`; + + } + } + + public deepCopy(): PostProcessorRegistry { + const copy = new PostProcessorRegistry(this.currentPostProcessors); + return copy; + } + + public shift(): Function | undefined { + const res = this.currentPostProcessors.shift(); + + if (res) { + return res.fn; + } + return undefined; + } + + + +} \ No newline at end of file diff --git a/src/libs/interfaces.ts b/src/libs/interfaces.ts index 54e839b2..89a7a5a0 100644 --- a/src/libs/interfaces.ts +++ b/src/libs/interfaces.ts @@ -1,3 +1,5 @@ +import { Profiler } from "../logger"; + export interface AccessorStaticInterface { [key: string]: { get: Function; @@ -29,6 +31,7 @@ export interface AttributesDefinitionInterface { export type ComponentConstructorInterface = new (element: HTMLElement) => ComponentInterface; export interface ComponentInterface { + profiler: Profiler; element: HTMLElement; created():void; attached():void; diff --git a/src/logger.ts b/src/logger.ts new file mode 100644 index 00000000..611723f1 --- /dev/null +++ b/src/logger.ts @@ -0,0 +1,192 @@ +import log from 'loglevel'; + + +const colors = { + reset: "\x1b[0m", + trace: "\x1b[38;2;169;169;169m", // Gray + debug: "\x1b[38;2;0;0;255m", // Blue + info: "\x1b[38;2;0;128;0m", // Green + warn: "\x1b[38;2;218;165;32m", // Yellow + error: "\x1b[38;2;255;0;0m", // Red +}; + +function formatMessage(level, messages) { + const timestamp = new Date().toISOString(); + const color = colors[level] || colors.reset; + + // Convert each message to a string, including objects + const formattedMessages = messages.map(msg => { + if (typeof msg === 'object') { + try { + return JSON.stringify(msg, null, 2); + } catch (error) { + return String(msg); + } + } + return String(msg); + }).join(' '); + + return `${color}[${timestamp}] ${formattedMessages}${colors.reset}`; +} + +var originalFactory = log.methodFactory; + +log.methodFactory = function (methodName, logLevel, loggerName) { + const rawMethod = originalFactory(methodName, logLevel, loggerName); + return function (...messages) { + rawMethod(formatMessage(methodName, messages)); + }; +}; + + +// Manage the DEBUG environment variable +if (import.meta.env?.VITE_DEBUG === 'True') { + log.setLevel('debug'); +} else { + log.setLevel('warn'); +} + + +// Async HOF to log render times and time execution +export function trackRenderAsync(fn: Function, context?: string) { + return async function (...args: any[]) { + + let componentName = context ? context : this.name ? this.name : this.constructor.name; + if (this.element.id) { + componentName += ` (id: ${this.element.id})`; + } else if (this.dataSrc) { + componentName += ` (data-src: ${this.dataSrc})`; + } else if (this.resourceId) { + componentName += ` (resourceId: ${this.resourceId})`; + } + + const startTime = performance.now(); + const result = await fn.apply(this, args); + const endTime = performance.now(); + const renderTime = endTime - startTime; + + if (this.profiler) { + this.profiler.updateStats(componentName, renderTime); + this.profiler.printStats() + } else { + log.debug(`Component ${componentName} rendered in ${renderTime.toFixed(2)} ms`); + } + + return result; + }; +} + + +// HOF to log render times and time execution +export function trackRender(fn: Function, context?: string) { + return async function (...args: any[]) { + + let componentName = context ? context : this.name ? this.name : this.constructor.name; + + if (this.element.id) { + componentName += ` (id: ${this.element.id})`; + } else if (this.dataSrc) { + componentName += ` (data-src: ${this.dataSrc})`; + } else if (this.resourceId) { + componentName += ` (resourceId: ${this.resourceId})`; + } + + const startTime = performance.now(); + const result = fn.apply(this, args); + const endTime = performance.now(); + const renderTime = endTime - startTime; + + if (this.profiler) { + this.profiler.updateStats(componentName, renderTime); + this.profiler.printStats() + } else { + log.debug(`Component ${componentName} rendered in ${renderTime.toFixed(2)} ms`); + } + + return result; + }; +} + + +export type PerformanceMetrics = { + renderCount: number; // Combien de fois le composant a été rendu + totalExecutionTime: number; // Temps total d'exécution (en ms) + lastExecutionTime: number; // Temps d'exécution lors du dernier rendu + averageExecutionTime: number; + minExecutionTime: number; + maxExecutionTime: number; +}; + +export class Profiler { + private stats: { [componentName: string]: PerformanceMetrics } = {}; + + constructor() { + this.stats = {}; + } + + private getOrCreateStats(componentName: string): PerformanceMetrics { + if (!this.stats[componentName]) { + this.stats[componentName] = { + renderCount: 0, + totalExecutionTime: 0, + lastExecutionTime: 0, + averageExecutionTime: 0, + minExecutionTime: Infinity, + maxExecutionTime: 0, + }; + } + return this.stats[componentName]; + } + + public getStats(componentName: string): PerformanceMetrics | undefined { + return this.stats[componentName]; + } + + public updateStats(componentName: string, renderTime: number): void { + const stats = this.getOrCreateStats(componentName); + stats.renderCount++; + stats.lastExecutionTime = renderTime; + stats.totalExecutionTime += renderTime; + stats.averageExecutionTime = stats.totalExecutionTime / stats.renderCount; + stats.minExecutionTime = Math.min(stats.minExecutionTime, renderTime); + stats.maxExecutionTime = Math.max(stats.maxExecutionTime, renderTime); + } + + private formatTime(time: number): string { + if (time >= 1000) { + return `${(time / 1000).toFixed(2)} seconds`; + } else { + return `${time.toFixed(2)} ms`; + } + } + + private formatComponentStats(componentName: string, stats: PerformanceMetrics): string { + return `\nComponent: ${componentName}\n` + + ` Render Count: ${stats.renderCount}\n` + + ` Total Execution Time: ${this.formatTime(stats.totalExecutionTime)}\n` + + ` Last Execution Time: ${this.formatTime(stats.lastExecutionTime)}\n` + + ` Average Execution Time: ${this.formatTime(stats.averageExecutionTime)}\n` + + ` Min Execution Time: ${this.formatTime(stats.minExecutionTime)}\n` + + ` Max Execution Time: ${this.formatTime(stats.maxExecutionTime)}\n`; + } + + public printStats(componentName: string): void { + let output = 'Component Performance Stats:\n'; + + if (componentName) { + const stats = this.stats[componentName]; + if (!stats) { + output += `Component ${componentName} not found.\n`; + } else { + output += this.formatComponentStats(componentName, stats); + } + } else { + for (const [name, stats] of Object.entries(this.stats)) { + output += this.formatComponentStats(name, stats); + } + } + log.debug(output); + } +} + +export { log as logger } \ No newline at end of file diff --git a/src/mixins/counterMixin.ts b/src/mixins/counterMixin.ts index ab6cc482..465a396e 100644 --- a/src/mixins/counterMixin.ts +++ b/src/mixins/counterMixin.ts @@ -1,6 +1,8 @@ import { html } from 'lit-html'; import { unsafeHTML } from 'lit-html/directives/unsafe-html'; import { evalTemplateString } from '../libs/helpers'; +import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; + const CounterMixin = { name: 'counter-mixin', @@ -16,9 +18,9 @@ const CounterMixin = { parentCounterDiv: null, }, attached() { - this.listPostProcessors.push(this.countResources.bind(this)); + this.listPostProcessors.attach(this.countResources.bind(this), 'CounterMixin:countResources'); }, - async countResources(resources: object[], listPostProcessors: Function[], div: HTMLElement, context: string) { + async countResources(resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string) { if (this.counterTemplate) { this.initParentCounterDiv(div); this.renderCallbacks.push({ // add counter template to render callback diff --git a/src/mixins/federationMixin.ts b/src/mixins/federationMixin.ts index 5b5b4ef7..cb1013fc 100644 --- a/src/mixins/federationMixin.ts +++ b/src/mixins/federationMixin.ts @@ -1,3 +1,4 @@ +import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; import { store } from '../libs/store/store'; import type { Resource } from './interfaces'; @@ -8,15 +9,15 @@ const FederationMixin = { containerFetched: null }, attached(): void { - this.listPostProcessors.push(this.fetchSources.bind(this)); + this.listPostProcessors.attach(this.fetchSources.bind(this), 'FederationMixin:fetchSources'); }, - async fetchSources(resources: Resource[], listPostProcessors: Function[], div: HTMLElement, context: string) { + async fetchSources(resources: Resource[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string) { this.containerFetched = []; let newResources: Resource[] = await this.getResources(resources); newResources = [...new Set(newResources)]; // remove possible duplicates const nextProcessor = listPostProcessors.shift(); - if(nextProcessor) await nextProcessor(newResources, listPostProcessors, div, context); + if (nextProcessor) await nextProcessor(newResources, listPostProcessors, div, context); }, async getResources(resources: Resource[]): Promise<Resource[]> { if (!resources) return []; diff --git a/src/mixins/filterMixin.ts b/src/mixins/filterMixin.ts index 4ce18311..0921aafd 100644 --- a/src/mixins/filterMixin.ts +++ b/src/mixins/filterMixin.ts @@ -1,6 +1,7 @@ import type { SearchQuery } from '../libs/interfaces'; import { searchInResources } from '../libs/filter'; import type { ServerSearchOptions } from '../libs/store/server-search'; +import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const FilterMixin = { name: 'filter-mixin', @@ -45,7 +46,7 @@ const FilterMixin = { // this.searchForm.component.attach(this); // is it necessary? this.searchForm.addEventListener('formChange', () => this.onServerSearchChange()); } else { - this.listPostProcessors.push(this.filterCallback.bind(this)); + this.listPostProcessors.attach(this.filterCallback.bind(this), 'FilterMixin:filterCallback'); } }, get filters(): SearchQuery { @@ -79,7 +80,7 @@ const FilterMixin = { } return; }, - async filterCallback(resources: object[], listPostProcessors: Function[], div: HTMLElement, context: string): Promise<void> { + async filterCallback(resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string): Promise<void> { if (this.filteredBy || this.searchFields) { if (!this.searchCount.has(context)) this.searchCount.set(context, 1); if (!this.searchForm) await this.createFilter(context); diff --git a/src/mixins/grouperMixin.ts b/src/mixins/grouperMixin.ts index ee844228..1a16d18f 100644 --- a/src/mixins/grouperMixin.ts +++ b/src/mixins/grouperMixin.ts @@ -1,4 +1,5 @@ import { generalComparator } from "../libs/helpers"; +import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const GrouperMixin = { name: 'grouper-mixin', @@ -26,9 +27,9 @@ const GrouperMixin = { }, }, attached() { - this.listPostProcessors.push(this.groupResources.bind(this)); + this.listPostProcessors.attach(this.groupResources.bind(this), 'GrouperMixin:groupResources'); }, - async groupResources(resources: object[], listPostProcessors: Function[], div: HTMLElement, context: string) { + async groupResources(resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string) { const nextProcessor = listPostProcessors.shift(); if (this.groupBy) { let groups = {}; @@ -52,7 +53,7 @@ const GrouperMixin = { for (let { group, parent } of parents) { if (nextProcessor) await nextProcessor( groups[group].resources, // give only resources from group - [...listPostProcessors], // copy post processors + listPostProcessors.deepCopy(), // copy post processors parent, // parent is group widget context + "_" + group ); diff --git a/src/mixins/highlighterMixin.ts b/src/mixins/highlighterMixin.ts index fce1050e..1e19135d 100644 --- a/src/mixins/highlighterMixin.ts +++ b/src/mixins/highlighterMixin.ts @@ -1,10 +1,12 @@ +import { PostProcessorRegistry } from "../libs/PostProcessorRegistry"; + const HighlighterMixin = { name: 'highlighter-mixin', use: [], attached(): void { - this.listPostProcessors.push(this.hightlightCallback.bind(this)); + this.listPostProcessors.attach(this.hightlightCallback.bind(this), 'HighlighterMixin:hightlightCallback'); }, - async hightlightCallback(resources: object[], listPostProcessors: Function[], div: HTMLElement, context: string): Promise<void> { + async hightlightCallback(resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string): Promise<void> { for (let attr of this.element.attributes) { if (attr.name.startsWith('highlight-')) { const field = attr.name.split('highlight-')[1]; diff --git a/src/mixins/listMixin.ts b/src/mixins/listMixin.ts index 2103a566..3e6ae80c 100644 --- a/src/mixins/listMixin.ts +++ b/src/mixins/listMixin.ts @@ -1,6 +1,7 @@ import { html, render } from 'lit-html'; import { preHTML } from '../libs/lit-helpers'; import { ifDefined } from 'lit-html/directives/if-defined'; +import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const ListMixin = { name: 'list-mixin', @@ -17,12 +18,12 @@ const ListMixin = { }, initialState: { // Processors functions to execute on the list before rendering - listPostProcessors: [], + listPostProcessors: new PostProcessorRegistry(), // Rendering to execute after all the processors have been executed renderCallbacks: [], }, created() { - this.listPostProcessors = []; + this.listPostProcessors = new PostProcessorRegistry(); this.renderCallbacks = []; }, appendSingleElt(parent: HTMLElement): void { @@ -40,6 +41,7 @@ const ListMixin = { } }, async populate(): Promise<void> { + const listPostProcessorsCopy = this.listPostProcessors.deepCopy(); const div = this.div; if (!this.resource) return; @@ -52,31 +54,31 @@ const ListMixin = { if (this.resource.isContainer?.()) { this.setElementAttribute("container"); - const listPostProcessors = [...this.listPostProcessors]; this.renderCallbacks = []; - listPostProcessors.push(this.renderDOM.bind(this)); - listPostProcessors.push(this.handleEmptyWidget.bind(this)); + listPostProcessorsCopy.attach(this.renderDOM.bind(this), 'ListMixin:renderDOM'); + listPostProcessorsCopy.attach(this.handleEmptyWidget.bind(this), 'ListMixin:handleEmptyWidget'); // Execute the first post-processor of the list - const nextProcessor = listPostProcessors.shift(); + const nextProcessor = listPostProcessorsCopy.shift(); + await nextProcessor( this.resource['ldp:contains'], - listPostProcessors, + listPostProcessorsCopy, div, this.dataSrc, ); } else if (this.arrayField && this.predicateName && this.resource[this.predicateName]) { this.setElementAttribute("container"); - const listPostProcessors = [...this.listPostProcessors]; this.renderCallbacks = []; - listPostProcessors.push(this.renderDOM.bind(this)); - listPostProcessors.push(this.handleEmptyWidget.bind(this)); + listPostProcessorsCopy.attach(this.renderDOM.bind(this), 'ListMixin:renderDOM'); + listPostProcessorsCopy.attach(this.handleEmptyWidget.bind(this), 'ListMixin:handleEmptyWidget'); // Execute the first post-processor of the list - const nextProcessor = listPostProcessors.shift(); + const nextProcessor = listPostProcessorsCopy.shift(); + await nextProcessor( await this.resource[this.predicateName], - listPostProcessors, + listPostProcessorsCopy, div, this.dataSrc, ); @@ -99,7 +101,7 @@ const ListMixin = { */ async renderDOM( resources: object[], - listPostProcessors: Function[], + listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string, ) { @@ -128,7 +130,7 @@ const ListMixin = { */ async handleEmptyWidget( resources: object[], - listPostProcessors: Function[], + listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string, ) { @@ -140,7 +142,7 @@ const ListMixin = { this.emptyWrapper = document.createElement('span') this.element.appendChild(this.emptyWrapper) } - + render(resources.length > 0 ? html`` : emptyWidgetTemplate, this.emptyWrapper); } diff --git a/src/mixins/paginateMixin.ts b/src/mixins/paginateMixin.ts index da421034..5a93feb2 100644 --- a/src/mixins/paginateMixin.ts +++ b/src/mixins/paginateMixin.ts @@ -1,4 +1,5 @@ import { html, TemplateResult } from "lit-html"; +import { PostProcessorRegistry } from "../libs/PostProcessorRegistry"; const PaginateMixin = { name: 'paginate-mixin', @@ -20,9 +21,9 @@ const PaginateMixin = { this.currentPage = []; }, attached(): void { - this.listPostProcessors.push(this.paginateCallback.bind(this)); + this.listPostProcessors.attach(this.paginateCallback.bind(this), 'PaginateMixin:paginateCallback'); }, - async paginateCallback(resources: object[], listPostProcessors: Function[], div: HTMLElement, context: string) { + async paginateCallback(resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string) { if (this.paginateBy > 0) { if (!this.currentPage[context]) this.currentPage[context] = 1; const parentDiv = this.initParentPaginationDiv(div, context); diff --git a/src/mixins/requiredMixin.ts b/src/mixins/requiredMixin.ts index 819da65b..04c6d193 100644 --- a/src/mixins/requiredMixin.ts +++ b/src/mixins/requiredMixin.ts @@ -1,10 +1,12 @@ +import { PostProcessorRegistry } from "../libs/PostProcessorRegistry"; + const RequiredMixin = { name: 'required-mixin', use: [], attached(): void { - this.listPostProcessors.push(this.requiredResources.bind(this)); + this.listPostProcessors.attach(this.requiredResources.bind(this), 'RequiredMixin:requiredResources'); }, - async requiredResources(resources: object[], listPostProcessors: Function[], div: HTMLElement, context: string): Promise<void> { + async requiredResources(resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string): Promise<void> { const displays: any[] = []; const requiredFields = Array.from((this.element as Element).attributes).filter(attr => attr.name.startsWith('required-')) .map(attr => { diff --git a/src/mixins/sorterMixin.ts b/src/mixins/sorterMixin.ts index 0734226d..a048d249 100644 --- a/src/mixins/sorterMixin.ts +++ b/src/mixins/sorterMixin.ts @@ -1,3 +1,5 @@ +import { PostProcessorRegistry } from "../libs/PostProcessorRegistry"; + const SorterMixin = { name: 'sorter-mixin', use: [], @@ -34,7 +36,7 @@ const SorterMixin = { randomOrder: null }, attached(): void { - this.listPostProcessors.push(this.orderCallback.bind(this)); + this.listPostProcessors.attach(this.orderCallback.bind(this), 'SorterMixin:orderCallback'); }, created(): void { this.randomOrder = []; @@ -50,7 +52,7 @@ const SorterMixin = { }); }, - async orderCallback(resources: object[], listPostProcessors: Function[], div: HTMLElement, context: string) { + async orderCallback(resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string) { if (this.orderBy) this.orderAsc = this.orderBy; // retrocompatibility. remove in 0.15 let sortingKey = ''; let orderValueToSort = ''; diff --git a/src/new-widgets/baseWidgetMixin.ts b/src/new-widgets/baseWidgetMixin.ts index a5cb6195..7bdd8a2f 100644 --- a/src/new-widgets/baseWidgetMixin.ts +++ b/src/new-widgets/baseWidgetMixin.ts @@ -1,3 +1,4 @@ +import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; import type { Template } from './interfaces'; import {render} from 'lit-html'; @@ -37,20 +38,20 @@ const BaseWidgetMixin = { }, }, initialState: { - listValueTransformations: [], - listTemplateAdditions: [], + listValueTransformations: new PostProcessorRegistry(), + listTemplateAdditions: new PostProcessorRegistry(), listAttributes: {}, - listCallbacks: [], + listCallbacks: new PostProcessorRegistry(), renderPlanned: false, }, get template() { return null }, created() { - this.listValueTransformations = []; + this.listValueTransformations = new PostProcessorRegistry(); this.listAttributes = {}; - this.listTemplateAdditions = []; - this.listCallbacks = []; + this.listTemplateAdditions = new PostProcessorRegistry(); + this.listCallbacks = new PostProcessorRegistry(); this.subscription = null; }, attached() { @@ -69,28 +70,27 @@ const BaseWidgetMixin = { } }, render() { - const listValueTransformations = [...this.listValueTransformations]; - listValueTransformations.push(this.renderTemplate.bind(this)); - - const nextProcessor = listValueTransformations.shift(); - nextProcessor(this.value, listValueTransformations); + const listValueTransformationsCopy = this.listValueTransformations.deepCopy(); + listValueTransformationsCopy.attach(this.renderTemplate.bind(this), "BaseWidgetMixin:renderTemplate"); + const nextProcessor = listValueTransformationsCopy.shift(); + nextProcessor(this.value, listValueTransformationsCopy); // Callbacks - const listCallbacks = [...this.listCallbacks]; - if (listCallbacks.length) { - const nextCallback = listCallbacks.shift(); - nextCallback(this.value, listCallbacks); + const listCallbacksCopy = this.listCallbacks.deepCopy(); + const nextCallback = listCallbacksCopy.shift(); + if (nextCallback) { + nextCallback(this.value, listCallbacksCopy); } this.element.dispatchEvent(new CustomEvent('widgetRendered', { bubbles: true })); }, renderTemplate(value: string) { const template: Template = this.template(value, { ...this.listAttributes }); - const listTemplateAdditions = [...this.listTemplateAdditions]; - listTemplateAdditions.push(this.templateToDOM.bind(this)); + const listTemplateAdditionsCopy = this.listTemplateAdditions.deepCopy(); + listTemplateAdditionsCopy.attach(this.templateToDOM.bind(this), "BaseWidgetMixin:templateToDOM"); - const nextProcessor = listTemplateAdditions.shift(); - nextProcessor(template, listTemplateAdditions); + const nextProcessor = listTemplateAdditionsCopy.shift(); + nextProcessor(template, listTemplateAdditionsCopy); }, templateToDOM(template: Template) { render(template, this.element); diff --git a/src/new-widgets/callbackMixins/autocompletionMixin.ts b/src/new-widgets/callbackMixins/autocompletionMixin.ts index 2bf8f68f..ca26673b 100644 --- a/src/new-widgets/callbackMixins/autocompletionMixin.ts +++ b/src/new-widgets/callbackMixins/autocompletionMixin.ts @@ -1,6 +1,7 @@ import { fuzzyCompare, importInlineCSS } from '../../libs/helpers'; import SlimSelect from 'slim-select'; import { TranslationMixin } from '../../mixins/translationMixin'; +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const AutocompletionMixin = { name: 'autocompletion-mixin', @@ -30,13 +31,13 @@ const AutocompletionMixin = { this.slimSelect = null; this.addToAttributes(true, 'autocomplete'); - this.listCallbacks.push(this.addCallback.bind(this)); + this.listCallbacks.attach(this.addCallback.bind(this), "AutocompletionMixin:addCallback"); }, detached() { if (this.slimSelect) this.slimSelect.destroy(); if (this.mutationObserver) this.mutationObserver.disconnect(); }, - addCallback(value: string, listCallbacks: Function[]) { + addCallback(value: string, listCallbacks: PostProcessorRegistry) { if (this.slimSelect) return; let select = this.element.querySelector('select'); if (select) { diff --git a/src/new-widgets/callbackMixins/richtextMixin.ts b/src/new-widgets/callbackMixins/richtextMixin.ts index 778185bf..707f91f5 100644 --- a/src/new-widgets/callbackMixins/richtextMixin.ts +++ b/src/new-widgets/callbackMixins/richtextMixin.ts @@ -2,6 +2,7 @@ import Quill from 'quill'; import deltaMd from 'delta-markdown-for-quill'; import { importInlineCSS } from '../../libs/helpers.js'; +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.js'; const RichtextMixin = { name: 'richtext-mixin', @@ -13,12 +14,12 @@ const RichtextMixin = { importInlineCSS('quill', () => import('quill/dist/quill.snow.css?inline')) this.quill = null; - this.listCallbacks.push(this.addCallback.bind(this)); + this.listCallbacks.attach(this.addCallback.bind(this), "RichtextMixin:addCallback"); }, getPlaceHolderValue() { return this.element.hasAttribute('placeholder') ? this.element.getAttribute('placeholder') : ''; }, - addCallback(value: string, listCallbacks: Function[]) { + addCallback(value: string, listCallbacks: PostProcessorRegistry) { if (this.quill == null) { var toolbarOptions = [ ['bold', 'italic'], diff --git a/src/new-widgets/templateAdditionMixins/addableMixin.ts b/src/new-widgets/templateAdditionMixins/addableMixin.ts index 5c396a8e..81916c9e 100644 --- a/src/new-widgets/templateAdditionMixins/addableMixin.ts +++ b/src/new-widgets/templateAdditionMixins/addableMixin.ts @@ -1,3 +1,4 @@ +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; import { spread } from '../../libs/lit-helpers'; import { html } from 'lit-html'; @@ -5,7 +6,7 @@ import { html } from 'lit-html'; const AddableMixin = { name: 'addable-mixin', created() { - this.listTemplateAdditions.push(this.addableValue.bind(this)); + this.listTemplateAdditions.attach(this.addableValue.bind(this), "AddableMixin:addableValue"); }, getAddableAttributes() { const addableAttr = (Array.from(this.element.attributes) as Attr[]).filter((a: Attr) => a.name.startsWith('addable-')); @@ -14,7 +15,7 @@ const AddableMixin = { if (!cleanAddableAttr.hasOwnProperty('data-src')) cleanAddableAttr['data-src'] = this.range; return cleanAddableAttr; }, - addableValue(template, listTemplateAdditions: Function[], attributes: object) { + addableValue(template, listTemplateAdditions: PostProcessorRegistry, attributes: object) { const addables = this.getAddableAttributes(attributes); const newTemplate = html` ${template} diff --git a/src/new-widgets/templateAdditionMixins/labelLastMixin.ts b/src/new-widgets/templateAdditionMixins/labelLastMixin.ts index b917a6c5..83b5b040 100644 --- a/src/new-widgets/templateAdditionMixins/labelLastMixin.ts +++ b/src/new-widgets/templateAdditionMixins/labelLastMixin.ts @@ -1,18 +1,19 @@ import { html } from 'lit-html'; +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const LabelLastMixin = { name: 'label-last-mixin', created() { - this.listTemplateAdditions.push(this.addLabelLast.bind(this)); + this.listTemplateAdditions.attach(this.addLabelLast.bind(this), "LabelLastMixin:addLabelLast"); }, - addLabelLast(template, listTemplateAdditions: Function[]) { + addLabelLast(template, listTemplateAdditions: PostProcessorRegistry) { const newTemplate = html` ${template} <label>${this.label || this.name}</label> `; const nextProcessor = listTemplateAdditions.shift(); - if(nextProcessor) nextProcessor(newTemplate, listTemplateAdditions); + if (nextProcessor) nextProcessor(newTemplate, listTemplateAdditions); } } diff --git a/src/new-widgets/templateAdditionMixins/labelMixin.ts b/src/new-widgets/templateAdditionMixins/labelMixin.ts index 7230dd45..c00fa01d 100644 --- a/src/new-widgets/templateAdditionMixins/labelMixin.ts +++ b/src/new-widgets/templateAdditionMixins/labelMixin.ts @@ -1,20 +1,21 @@ import { html } from 'lit-html'; import { uniqID } from '../../libs/helpers'; +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const LabelMixin = { name: 'label-mixin', created() { this.listAttributes['id'] = uniqID(); - this.listTemplateAdditions.push(this.addLabel.bind(this)); + this.listTemplateAdditions.attach(this.addLabel.bind(this), "LabelMixin:addLabel"); }, - addLabel(template, listTemplateAdditions: Function[]) { + addLabel(template, listTemplateAdditions: PostProcessorRegistry) { const newTemplate = html` <label for="${this.listAttributes['id']}">${this.label || this.name}</label> ${template} `; const nextProcessor = listTemplateAdditions.shift(); - if(nextProcessor) nextProcessor(newTemplate, listTemplateAdditions); + if (nextProcessor) nextProcessor(newTemplate, listTemplateAdditions); } } diff --git a/src/new-widgets/templatesDependencies/editableMixin.ts b/src/new-widgets/templatesDependencies/editableMixin.ts index b6e853c0..d5e87c0a 100644 --- a/src/new-widgets/templatesDependencies/editableMixin.ts +++ b/src/new-widgets/templatesDependencies/editableMixin.ts @@ -2,6 +2,7 @@ import { StoreMixin } from '../../mixins/storeMixin'; import { store } from '../../libs/store/store'; import { html } from 'lit-html'; +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const EditableMixin = { name: 'editable-mixin', @@ -24,15 +25,15 @@ const EditableMixin = { } }, created() { - this.listTemplateAdditions.push(this.addEditButton.bind(this)); + this.listTemplateAdditions.attach(this.addEditButton.bind(this), "EditableMixin:addEditButton"); }, - addEditButton(template, listTemplateAdditions: Function[]) { + addEditButton(template, listTemplateAdditions: PostProcessorRegistry) { let newTemplate: any = null; if (this.editable !== null) { newTemplate = html`${template}<button @click=${this.activateEditableField.bind(this)}>${this.buttonLabel}</button>`; } const nextProcessor = listTemplateAdditions.shift(); - if(nextProcessor) nextProcessor(newTemplate || template, listTemplateAdditions); + if (nextProcessor) nextProcessor(newTemplate || template, listTemplateAdditions); }, activateEditableField(e: Event): void { const editableField = this.element.querySelector('[data-editable]'); diff --git a/src/new-widgets/templatesDependencies/multipleFormMixin.ts b/src/new-widgets/templatesDependencies/multipleFormMixin.ts index 83e5d27f..161ac10f 100644 --- a/src/new-widgets/templatesDependencies/multipleFormMixin.ts +++ b/src/new-widgets/templatesDependencies/multipleFormMixin.ts @@ -1,3 +1,4 @@ +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; import { StoreMixin } from '../../mixins/storeMixin'; const MultipleFormMixin = { @@ -47,7 +48,7 @@ const MultipleFormMixin = { } }, created() { - this.listValueTransformations.push(this.setDataSrc.bind(this)); + this.listValueTransformations.attach(this.setDataSrc.bind(this), "MultipleFormMixin:setDataSrc"); this.listAttributes['children'] = []; this.listAttributes['addLabel'] = this.addLabel; @@ -63,7 +64,7 @@ const MultipleFormMixin = { this.element.dispatchEvent(new Event('change', {bubbles: true})); }; }, - setDataSrc(value: string, listValueTransformations: Function[]) { + setDataSrc(value: string, listValueTransformations: PostProcessorRegistry) { if (value && value !== this.dataSrc) { try { if (Array.isArray(JSON.parse(value))) { @@ -76,7 +77,7 @@ const MultipleFormMixin = { } const nextProcessor = listValueTransformations.shift(); - if(nextProcessor) nextProcessor(value, listValueTransformations); + if (nextProcessor) nextProcessor(value, listValueTransformations); }, populate() { if (!this.resource || !this.resource['ldp:contains']) return; diff --git a/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts b/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts index 79f3c626..5c067b3d 100644 --- a/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts +++ b/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts @@ -1,3 +1,4 @@ +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; import { StoreMixin } from '../../mixins/storeMixin'; const MultipleselectFormMixin = { @@ -34,9 +35,9 @@ const MultipleselectFormMixin = { } }, created() { - this.listValueTransformations.push(this.setDataSrc.bind(this)); + this.listValueTransformations.attach(this.setDataSrc.bind(this), "MultipleselectFormMixin:setDataSrc"); }, - setDataSrc(value: string, listValueTransformations: Function[]) { + setDataSrc(value: string, listValueTransformations: PostProcessorRegistry) { if (value && value !== this.dataSrc) { try { let values = JSON.parse(value); diff --git a/src/new-widgets/templatesDependencies/rangeMixin.ts b/src/new-widgets/templatesDependencies/rangeMixin.ts index 826765f3..d068d9d5 100644 --- a/src/new-widgets/templatesDependencies/rangeMixin.ts +++ b/src/new-widgets/templatesDependencies/rangeMixin.ts @@ -3,6 +3,7 @@ import { StoreMixin } from '../../mixins/storeMixin'; import { SorterMixin } from '../../mixins/sorterMixin'; import { FederationMixin } from '../../mixins/federationMixin'; import type { Resource } from '../../mixins/interfaces'; +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const RangeMixin = { name: 'range-mixin', @@ -60,22 +61,22 @@ const RangeMixin = { } }, initialState: { - listPostProcessors: [], + listPostProcessors: new PostProcessorRegistry(), }, created() { - this.listPostProcessors = []; + this.listPostProcessors = new PostProcessorRegistry(); this.listAttributes['optionLabel'] = this.optionLabel; this.listAttributes['optionValue'] = this.optionValue; }, async populate() { const resources = this.resource ? this.resource['ldp:contains'] : []; - const listPostProcessors = [...this.listPostProcessors]; - listPostProcessors.push(this.setRangeAttribute.bind(this)); + const listPostProcessorsCopy = this.listPostProcessors.deepCopy(); + listPostProcessorsCopy.attach(this.setRangeAttribute.bind(this), 'RangeMixin:setRangeAttribute'); - const nextProcessor = listPostProcessors.shift(); + const nextProcessor = listPostProcessorsCopy.shift(); await nextProcessor( resources, - listPostProcessors, + listPostProcessorsCopy, null, this.dataSrc, ); diff --git a/src/new-widgets/valueTransformationMixins/autolinkMixin.ts b/src/new-widgets/valueTransformationMixins/autolinkMixin.ts index 1ffeb16f..27726bd7 100644 --- a/src/new-widgets/valueTransformationMixins/autolinkMixin.ts +++ b/src/new-widgets/valueTransformationMixins/autolinkMixin.ts @@ -1,11 +1,12 @@ import {Autolinker} from 'autolinker'; +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const AutolinkMixin = { name: 'autolink-mixin', created() { - this.listValueTransformations.push(this.transformValue.bind(this)); + this.listValueTransformations.attach(this.transformValue.bind(this), "AutolinkMixin:transformValue"); }, - transformValue(value: string, listValueTransformations: Function[]) { + transformValue(value: string, listValueTransformations: PostProcessorRegistry) { const template = document.createElement('template'); template.innerHTML = Autolinker.link(value); diff --git a/src/new-widgets/valueTransformationMixins/dateMixin.ts b/src/new-widgets/valueTransformationMixins/dateMixin.ts index 0ac4961c..d1a8a8cb 100644 --- a/src/new-widgets/valueTransformationMixins/dateMixin.ts +++ b/src/new-widgets/valueTransformationMixins/dateMixin.ts @@ -1,9 +1,11 @@ +import { PostProcessorRegistry } from "../../libs/PostProcessorRegistry"; + const DateMixin = { name: 'date-mixin', created() { - this.listValueTransformations.push(this.transformValue.bind(this)); + this.listValueTransformations.attach(this.transformValue.bind(this), "DateMixin:transformValue"); }, - transformValue(value: string, listValueTransformations: Function[]) { + transformValue(value: string, listValueTransformations: PostProcessorRegistry) { try { // workaround for giving a specific-formatted value to the form widget this.listAttributes['originalValue'] = this.formatDateForInput(value); diff --git a/src/new-widgets/valueTransformationMixins/dateTimeMixin.ts b/src/new-widgets/valueTransformationMixins/dateTimeMixin.ts index de6872f7..49407051 100644 --- a/src/new-widgets/valueTransformationMixins/dateTimeMixin.ts +++ b/src/new-widgets/valueTransformationMixins/dateTimeMixin.ts @@ -1,9 +1,11 @@ +import { PostProcessorRegistry } from "../../libs/PostProcessorRegistry"; + const DateTimeMixin = { name: 'date-time-mixin', created() { - this.listValueTransformations.push(this.transformValue.bind(this)); + this.listValueTransformations.attach(this.transformValue.bind(this), "DateTimeMixin:transformValue"); }, - transformValue(value: string, listValueTransformations: Function[]) { + transformValue(value: string, listValueTransformations: PostProcessorRegistry) { const newValue = value ? new Date(value).toLocaleString() : value; const nextProcessor = listValueTransformations.shift(); diff --git a/src/new-widgets/valueTransformationMixins/markdownMixin.ts b/src/new-widgets/valueTransformationMixins/markdownMixin.ts index def05d0a..de847e64 100644 --- a/src/new-widgets/valueTransformationMixins/markdownMixin.ts +++ b/src/new-widgets/valueTransformationMixins/markdownMixin.ts @@ -2,13 +2,14 @@ import { unsafeHTML } from 'lit-html/directives/unsafe-html'; import markdownit from 'markdown-it'; import mila from 'markdown-it-link-attributes'; +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const MarkdownMixin = { name: 'markdown-mixin', created() { - this.listValueTransformations.push(this.transformValue.bind(this)); + this.listValueTransformations.attach(this.transformValue.bind(this), "MarkdownMixin:transformValue"); }, - transformValue(value: string, listValueTransformations: Function[]) { + transformValue(value: string, listValueTransformations: PostProcessorRegistry) { let newValue: any = ''; if (value) { const md = markdownit({ @@ -29,7 +30,7 @@ const MarkdownMixin = { } const nextProcessor = listValueTransformations.shift(); - if(nextProcessor) nextProcessor(newValue, listValueTransformations); + if (nextProcessor) nextProcessor(newValue, listValueTransformations); } } diff --git a/src/new-widgets/valueTransformationMixins/multilineMixin.ts b/src/new-widgets/valueTransformationMixins/multilineMixin.ts index 6c97b475..ff58b82b 100644 --- a/src/new-widgets/valueTransformationMixins/multilineMixin.ts +++ b/src/new-widgets/valueTransformationMixins/multilineMixin.ts @@ -1,15 +1,16 @@ import { unsafeHTML } from 'lit-html/directives/unsafe-html'; +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const MultilineMixin = { name: 'multiline-mixin', created() { - this.listValueTransformations.push(this.transformValue.bind(this)); + this.listValueTransformations.attach(this.transformValue.bind(this), "MultilineMixin:transformValue"); }, - transformValue(value: string, listValueTransformations: Function[]) { + transformValue(value: string, listValueTransformations: PostProcessorRegistry) { const newValue = value ? unsafeHTML(value.replace(/\n/g, "<br/>")) : value; const nextProcessor = listValueTransformations.shift(); - if(nextProcessor) nextProcessor(newValue, listValueTransformations); + if (nextProcessor) nextProcessor(newValue, listValueTransformations); } } diff --git a/src/new-widgets/valueTransformationMixins/oembedMixin.ts b/src/new-widgets/valueTransformationMixins/oembedMixin.ts index 8a8c08fc..04493de0 100644 --- a/src/new-widgets/valueTransformationMixins/oembedMixin.ts +++ b/src/new-widgets/valueTransformationMixins/oembedMixin.ts @@ -1,4 +1,5 @@ import { unsafeHTML } from 'lit-html/directives/unsafe-html'; +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const OembedMixin = { name: 'oembed-mixin', @@ -6,9 +7,9 @@ const OembedMixin = { existingOembed: null, }, created(): void { - this.listValueTransformations.push(this.transformValue.bind(this)); + this.listValueTransformations.attach(this.transformValue.bind(this), "OembedMixin:transformValue"); }, - async transformValue(value: string, listValueTransformations: Function[]) { + async transformValue(value: string, listValueTransformations: PostProcessorRegistry) { if (!value) return; if (this.existingOembed == null) { const response = await fetch(this.value); @@ -17,7 +18,7 @@ const OembedMixin = { const newValue = unsafeHTML(this.existingOembed.html); const nextProcessor = listValueTransformations.shift(); - if(nextProcessor) nextProcessor(newValue, listValueTransformations); + if (nextProcessor) nextProcessor(newValue, listValueTransformations); } } -- GitLab From 2d224e4201478200d121d110def1f1c7683906be Mon Sep 17 00:00:00 2001 From: Anastasia Kryukova <anastasia.kryukova@protonmail.com> Date: Thu, 7 Nov 2024 11:36:10 +0100 Subject: [PATCH 10/66] Fix/853 update the version of lit we are using --- package-lock.json | 50 +++- package.json | 2 +- src/components/solid-calendar.ts | 6 +- src/components/solid-delete.ts | 7 +- src/components/solid-display.ts | 4 +- src/components/solid-form-search.ts | 11 +- src/components/solid-form.ts | 19 +- src/components/solid-lang.ts | 10 +- src/components/solid-map.ts | 4 +- src/components/solid-member-add.ts | 4 +- src/components/solid-member-delete.ts | 8 +- src/components/solid-membership.ts | 4 +- src/components/solid-table.ts | 29 +- src/components/solid-widget.ts | 4 +- src/index.ts | 8 +- src/libs/lit-helpers.ts | 280 ++++++++++-------- src/mixins/counterMixin.ts | 4 +- src/mixins/listMixin.ts | 8 +- src/mixins/paginateMixin.ts | 2 +- src/mixins/serverPaginationMixin.ts | 2 +- src/mixins/validationMixin.ts | 11 +- src/mixins/widgetMixin.ts | 17 +- src/new-widgets/baseWidgetMixin.ts | 2 +- .../templateAdditionMixins/addableMixin.ts | 2 +- .../templateAdditionMixins/labelLastMixin.ts | 7 +- .../templateAdditionMixins/labelMixin.ts | 7 +- .../templates/defaultTemplatesDirectory.ts | 4 +- .../templates/displayTemplatesDirectory.ts | 17 +- .../templates/formTemplatesDirectory.ts | 4 +- .../templates/groupTemplatesDirectory.ts | 7 +- .../templates/setTemplatesDirectory.ts | 2 +- .../templatesDependencies/editableMixin.ts | 2 +- .../markdownMixin.ts | 2 +- .../multilineMixin.ts | 2 +- .../valueTransformationMixins/oembedMixin.ts | 2 +- 35 files changed, 279 insertions(+), 275 deletions(-) diff --git a/package-lock.json b/package-lock.json index 54ef83a8..0d2b8077 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "cors": "^2.8.5", + "lit": "^3.2.1", "loglevel": "^1.9.1" }, "devDependencies": { @@ -32,7 +33,6 @@ "jsonld-context-parser": "^1.3.4", "leaflet": "1.9.4", "leaflet.markercluster": "1.5.3", - "lit-html": "^1.4.1", "markdown-it": "^14.1.0", "markdown-it-link-attributes": "4.0.1", "pubsub-js": "^1.9.4", @@ -602,6 +602,19 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@lit-labs/ssr-dom-shim": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.2.1.tgz", + "integrity": "sha512-wx4aBmgeGvFmOKucFKY+8VFJSYZxs9poN3SDNQFF6lT6NrQUnHiPB2PWz2sc4ieEcAaYYzN+1uWahEeTq2aRIQ==" + }, + "node_modules/@lit/reactive-element": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-2.0.4.tgz", + "integrity": "sha512-GFn91inaUa2oHLak8awSIigYz0cU0Payr1rcFsrkf5OJ5eSPxElyZfKh0f2p9FsTiZWXQdWGJeXZICEfXXYSXQ==", + "dependencies": { + "@lit-labs/ssr-dom-shim": "^1.2.0" + } + }, "node_modules/@rckeller/cypress-unfetch": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@rckeller/cypress-unfetch/-/cypress-unfetch-1.0.1.tgz", @@ -939,6 +952,11 @@ "integrity": "sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ==", "dev": true }, + "node_modules/@types/trusted-types": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", + "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==" + }, "node_modules/@types/yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.0.tgz", @@ -2967,11 +2985,33 @@ } } }, + "node_modules/lit": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/lit/-/lit-3.2.1.tgz", + "integrity": "sha512-1BBa1E/z0O9ye5fZprPtdqnc0BFzxIxTTOO/tQFmyC/hj1O3jL4TfmLBw0WEwjAokdLwpclkvGgDJwTIh0/22w==", + "dependencies": { + "@lit/reactive-element": "^2.0.4", + "lit-element": "^4.1.0", + "lit-html": "^3.2.0" + } + }, + "node_modules/lit-element": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-4.1.1.tgz", + "integrity": "sha512-HO9Tkkh34QkTeUmEdNYhMT8hzLid7YlMlATSi1q4q17HE5d9mrrEHJ/o8O2D0cMi182zK1F3v7x0PWFjrhXFew==", + "dependencies": { + "@lit-labs/ssr-dom-shim": "^1.2.0", + "@lit/reactive-element": "^2.0.4", + "lit-html": "^3.2.0" + } + }, "node_modules/lit-html": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-1.4.1.tgz", - "integrity": "sha512-B9btcSgPYb1q4oSOb/PrOT6Z/H+r6xuNzfH4lFli/AWhYwdtrgQkQWBbIc6mdnf6E2IL3gDXdkkqNktpU0OZQA==", - "dev": true + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-3.2.1.tgz", + "integrity": "sha512-qI/3lziaPMSKsrwlxH/xMgikhQ0EGOX2ICU73Bi/YHFvz2j/yMCIrw4+puF2IpQ4+upd3EWbvnHM9+PnJn48YA==", + "dependencies": { + "@types/trusted-types": "^2.0.2" + } }, "node_modules/lodash": { "version": "4.17.21", diff --git a/package.json b/package.json index 052d3ca3..2e14ae8c 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,6 @@ "jsonld-context-parser": "^1.3.4", "leaflet": "1.9.4", "leaflet.markercluster": "1.5.3", - "lit-html": "^1.4.1", "markdown-it": "^14.1.0", "markdown-it-link-attributes": "4.0.1", "pubsub-js": "^1.9.4", @@ -98,6 +97,7 @@ }, "dependencies": { "cors": "^2.8.5", + "lit": "^3.2.1", "loglevel": "^1.9.1" } } diff --git a/src/components/solid-calendar.ts b/src/components/solid-calendar.ts index ea14e232..90fac451 100644 --- a/src/components/solid-calendar.ts +++ b/src/components/solid-calendar.ts @@ -6,7 +6,7 @@ import { store } from '../libs/store/store'; import { importInlineCSS, uniqID } from '../libs/helpers'; import Calendar from 'tui-calendar'; -import { html, render } from 'lit-html'; +import { html, render } from 'lit'; export const SolidCalendar = { name: 'solid-calendar', @@ -22,9 +22,7 @@ export const SolidCalendar = { importInlineCSS('tui-calendar', () => import('tui-calendar/dist/tui-calendar.css?inline')) const id = uniqID(); - const template = html` - <div id=${id} style="width:100%;height:100%;"></div> - `; + const template = html`<div id=${id} style="width:100%;height:100%;"></div>`; render(template, this.element); this.calendar = new Calendar(this.element.querySelector(`#${id}`), { defaultView: 'month' }); this.calendar.on('clickSchedule', this.dispatchSelect.bind(this)); diff --git a/src/components/solid-delete.ts b/src/components/solid-delete.ts index e755fb92..d0fe9f04 100644 --- a/src/components/solid-delete.ts +++ b/src/components/solid-delete.ts @@ -4,7 +4,7 @@ import { NextMixin } from '../mixins/nextMixin'; import { ValidationMixin } from '../mixins/validationMixin'; import { AttributeBinderMixin } from '../mixins/attributeBinderMixin'; -import { html, render } from 'lit-html'; +import { html, render } from 'lit'; import { ContextMixin } from '../mixins/contextMixin'; import { trackRenderAsync } from '../logger'; @@ -65,10 +65,7 @@ export const SolidDelete = { render: trackRenderAsync( async function(): Promise<void> { await this.replaceAttributesData(false); - const button = html` - <button @click=${this.delete.bind(this)}>${this.dataLabel || this.t("solid-delete.button")}</button> - ${this.getModalDialog()} - `; + const button = html`<button @click=${this.delete.bind(this)}>${this.dataLabel || this.t("solid-delete.button")}</button>${this.getModalDialog()}`; render(button, this.element); }, "SolidDelete:render" diff --git a/src/components/solid-display.ts b/src/components/solid-display.ts index 21f89d82..34c00411 100644 --- a/src/components/solid-display.ts +++ b/src/components/solid-display.ts @@ -13,8 +13,8 @@ import { NextMixin } from '../mixins/nextMixin'; import { RequiredMixin } from '../mixins/requiredMixin'; import { spread } from '../libs/lit-helpers'; -import { html, render } from 'lit-html'; -import { ifDefined } from 'lit-html/directives/if-defined'; +import { html, render } from 'lit'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; import { trackRenderAsync } from '../logger'; diff --git a/src/components/solid-form-search.ts b/src/components/solid-form-search.ts index 66433c04..f49336dc 100644 --- a/src/components/solid-form-search.ts +++ b/src/components/solid-form-search.ts @@ -5,8 +5,8 @@ import { ContextMixin } from '../mixins/contextMixin'; import type { WidgetInterface } from '../mixins/interfaces'; import { newWidgetFactory } from '../new-widgets/new-widget-factory'; -import { html, render } from 'lit-html'; -import { ifDefined } from 'lit-html/directives/if-defined'; +import { html, render } from 'lit'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { uniqID } from '../libs/helpers'; import type { SearchQuery, FilterEventOptions } from '../libs/interfaces'; import { trackRenderAsync } from '../logger'; @@ -185,11 +185,8 @@ export const SolidFormSearch = { getSubmitTemplate() { return html` <div class=${ifDefined(this.classSubmitButton)}> - ${this.submitWidget === 'button' ? html` - <button type="submit">${this.submitButton || ''}</button> - ` : html` - <input type="submit" value=${ifDefined(this.submitButton || undefined)}> - `} + ${this.submitWidget === 'button' ? html`<button type="submit">${this.submitButton || ''}</button>` : + html`<input type="submit" value=${ifDefined(this.submitButton || undefined)}>`} </div> ` }, diff --git a/src/components/solid-form.ts b/src/components/solid-form.ts index 7e2af66c..0fa821ac 100644 --- a/src/components/solid-form.ts +++ b/src/components/solid-form.ts @@ -7,8 +7,8 @@ import { store } from '../libs/store/store'; import { setDeepProperty, transformArrayToContainer } from '../libs/helpers'; import type { WidgetInterface } from '../mixins/interfaces'; -import { html, render } from 'lit-html'; -import { ifDefined } from 'lit-html/directives/if-defined'; +import { html, render } from 'lit'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { trackRenderAsync } from '../logger'; export const SolidForm = { @@ -234,9 +234,7 @@ export const SolidForm = { showError(e: object) { let errors = Object.entries(e).filter(field => !field[0].startsWith('@context')); this.displayErrorMessage(errors); - const errorTemplate = html` - <p>${this.t('solid-form.validation-error')}</p> - `; + const errorTemplate = html`<p>${this.t('solid-form.validation-error')}</p>`; // Validation message in english ? const parentElement = this.element.querySelector('[data-id=error]'); @@ -270,11 +268,8 @@ export const SolidForm = { getSubmitTemplate() { return html` <div class=${ifDefined(this.classSubmitButton)}> - ${this.submitWidget === 'button' ? html` - <button type="submit">${this.submitButton || this.t("solid-form.submit-button")}</button> - ` : html` - <input type="submit" value=${this.submitButton || this.t("solid-form.submit-button")}> - `} + ${this.submitWidget === 'button' ? html`<button type="submit">${this.submitButton || this.t("solid-form.submit-button")}</button>` : + html`<input type="submit" value=${this.submitButton || this.t("solid-form.submit-button")}>`} </div> ` }, @@ -296,9 +291,7 @@ export const SolidForm = { ${this.element.hasAttribute('reset') ? html`<input type="reset" />` : ''} </form> - ` : html` - ${widgetTemplates} - ` + ` : html`${widgetTemplates}` } ${this.getModalDialog()} `; diff --git a/src/components/solid-lang.ts b/src/components/solid-lang.ts index 82b5c254..1902511f 100644 --- a/src/components/solid-lang.ts +++ b/src/components/solid-lang.ts @@ -1,7 +1,7 @@ import { Sib } from '../libs/Sib'; import { store } from '../libs/store/store'; -import { html, render } from 'lit-html'; +import { html, render } from 'lit'; export const SolidLang = { name: 'solid-lang', @@ -27,13 +27,7 @@ export const SolidLang = { }, render() { - let template = html` - <button - @click=${this.languageLoader.bind(this)} - > - ${this.dataLabel} - </button> - `; + let template = html`<button @click=${this.languageLoader.bind(this)}>${this.dataLabel}</button>`; render(template, this.element); } diff --git a/src/components/solid-map.ts b/src/components/solid-map.ts index 3c3d0a06..27eb5692 100644 --- a/src/components/solid-map.ts +++ b/src/components/solid-map.ts @@ -15,8 +15,8 @@ import { spread } from '../libs/lit-helpers'; import L, { MarkerOptions } from 'https://cdn.skypack.dev/leaflet'; // TODO : revert to "leaflet" when apps up to date import 'https://cdn.skypack.dev/leaflet.markercluster'; // TODO : revert to "leaflet.markercluster" when apps up to date -import { html, render } from 'lit-html'; -import { ifDefined } from 'lit-html/directives/if-defined'; +import { html, render } from 'lit'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; import { trackRenderAsync } from '../logger'; diff --git a/src/components/solid-member-add.ts b/src/components/solid-member-add.ts index b58d4c90..c9615eae 100644 --- a/src/components/solid-member-add.ts +++ b/src/components/solid-member-add.ts @@ -3,11 +3,11 @@ import { base_context, store } from '../libs/store/store'; import { NextMixin } from '../mixins/nextMixin'; import { ValidationMixin } from '../mixins/validationMixin'; -import { html, render } from 'lit-html'; +import { html, render } from 'lit'; import { ContextMixin } from '../mixins/contextMixin'; import { newWidgetFactory } from '../new-widgets/new-widget-factory'; import { StoreMixin } from '../mixins/storeMixin'; -import { ifDefined } from 'lit-html/directives/if-defined'; +import { ifDefined } from 'lit/directives/if-defined.js'; export const SolidMemberAdd = { name: 'solid-member-add', diff --git a/src/components/solid-member-delete.ts b/src/components/solid-member-delete.ts index eaf41c56..e9dc1260 100644 --- a/src/components/solid-member-delete.ts +++ b/src/components/solid-member-delete.ts @@ -2,9 +2,9 @@ import { Sib } from '../libs/Sib'; import { base_context, store } from '../libs/store/store'; import { NextMixin } from '../mixins/nextMixin'; import { ValidationMixin } from '../mixins/validationMixin'; -import { ifDefined } from 'lit-html/directives/if-defined'; +import { ifDefined } from 'lit/directives/if-defined.js'; -import { html, render } from 'lit-html'; +import { html, render } from 'lit'; import { ContextMixin } from '../mixins/contextMixin'; import { trackRenderAsync } from '../logger'; @@ -142,9 +142,7 @@ export const SolidMemberDelete = { </solid-ac-checker> `; } else { - button = html` - <span>${this.dataUnknownMember || this.t("solid-member-unknown.span")}</span> - `; + button = html`<span>${this.dataUnknownMember || this.t("solid-member-unknown.span")}</span>`; } render(button, this.element); }, "SolidMemberDelete:render") diff --git a/src/components/solid-membership.ts b/src/components/solid-membership.ts index 338556b2..3732fde6 100644 --- a/src/components/solid-membership.ts +++ b/src/components/solid-membership.ts @@ -3,9 +3,9 @@ import { base_context, store } from '../libs/store/store'; import { NextMixin } from '../mixins/nextMixin'; import { ValidationMixin } from '../mixins/validationMixin'; -import { html, render } from 'lit-html'; +import { html, render } from 'lit'; import { ContextMixin } from '../mixins/contextMixin'; -import { ifDefined } from 'lit-html/directives/if-defined'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { trackRenderAsync } from '../logger'; export const SolidMembership = { diff --git a/src/components/solid-table.ts b/src/components/solid-table.ts index 46005d7b..e38c081e 100644 --- a/src/components/solid-table.ts +++ b/src/components/solid-table.ts @@ -13,8 +13,8 @@ import { FederationMixin } from '../mixins/federationMixin'; import { HighlighterMixin } from '../mixins/highlighterMixin'; import { RequiredMixin } from '../mixins/requiredMixin'; -import { html, render } from 'lit-html'; -import { until } from 'lit-html/directives/until'; +import { html, render } from 'lit'; +import { until } from 'lit/directives/until.js'; import { spread } from '../libs/lit-helpers'; import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; import { trackRenderAsync } from '../logger'; @@ -143,14 +143,8 @@ export const SolidTable = { getHeader(fields: string[]) { let template = html` <tr> - ${this.selectable !== null ? html` - <th> - <input type="checkbox" @change="${this.selectAll.bind(this)}" /> - </th>` : ''} - ${fields.map((field: string) => html` - <th> - ${this.element.hasAttribute('label-'+field) ? this.element.getAttribute('label-'+field) : field} - </th>`)} + ${this.selectable !== null ? html`<th><input type="checkbox" @change="${this.selectAll.bind(this)}" /></th>` : ''} + ${fields.map((field: string) => html`<th>${this.element.hasAttribute('label-'+field) ? this.element.getAttribute('label-'+field) : field}</th>`)} </tr> ` return template; @@ -164,10 +158,7 @@ export const SolidTable = { const resource = await store.getData(resourceId, this.context); let template = html` <tr data-resource="${resourceId}"> - ${this.selectable !== null ? html` - <td> - <input type="checkbox" data-selection /> - </td>` : ''} + ${this.selectable !== null ? html`<td><input type="checkbox" data-selection /></td>` : ''} ${fields.map((field: string) => html`<td>${until(this.createCellWidget(field, resource))}</td>`)} </tr> ` @@ -181,10 +172,7 @@ export const SolidTable = { async appendSingleElt(parent: HTMLElement): Promise<void> { const fields = await this.getFields(); - const template = html` - ${this.header !== null ? this.getHeader(fields) : ''} - ${until(this.getChildTemplate(this.resource['@id'], fields))} - `; + const template = html`${this.header !== null ? this.getHeader(fields) : ''}${until(this.getChildTemplate(this.resource['@id'], fields))}`; render(template, parent); }, @@ -208,10 +196,7 @@ export const SolidTable = { const childTemplates = await Promise.all( resources.map(r => r ? this.getChildTemplate(r['@id'], fields) : null) ); - const template = html` - ${this.header !== null ? this.getHeader(fields) : ''} - ${childTemplates} - `; // create a child template for each resource + const template = html`${this.header !== null ? this.getHeader(fields) : ''}${childTemplates}`; // create a child template for each resource render(template, div); // Re-select the right lines diff --git a/src/components/solid-widget.ts b/src/components/solid-widget.ts index 09a2853d..e8d30db4 100644 --- a/src/components/solid-widget.ts +++ b/src/components/solid-widget.ts @@ -4,8 +4,8 @@ import { BaseWidgetMixin } from '../new-widgets/baseWidgetMixin'; import { FormMixin } from '../new-widgets/templatesDependencies/formMixin'; import { ActionMixin } from '../new-widgets/attributeMixins/actionMixin'; import { evalTemplateString } from '../libs/helpers'; -import { html, render } from 'lit-html'; -import { unsafeHTML } from 'lit-html/directives/unsafe-html'; +import { html, render } from 'lit'; +import { unsafeHTML } from 'lit/directives/unsafe-html.js'; export const SolidWidget = { name: 'solid-widget', diff --git a/src/index.ts b/src/index.ts index bc7b32ce..680d5358 100644 --- a/src/index.ts +++ b/src/index.ts @@ -46,10 +46,10 @@ import { widgetFactory } from './widgets/widget-factory'; import * as Helpers from './libs/helpers'; // lit-html -import { html, render } from 'lit-html'; -import { ifDefined } from 'lit-html/directives/if-defined'; -import { until } from 'lit-html/directives/until'; -import { unsafeHTML } from 'lit-html/directives/unsafe-html'; +import { html, render } from 'lit'; +import { ifDefined } from 'lit/directives/if-defined.js'; +import { until } from 'lit/directives/until.js'; +import { unsafeHTML } from 'lit/directives/unsafe-html.js'; export { // Components diff --git a/src/libs/lit-helpers.ts b/src/libs/lit-helpers.ts index 90d61adb..b5553d67 100644 --- a/src/libs/lit-helpers.ts +++ b/src/libs/lit-helpers.ts @@ -2,167 +2,199 @@ * Spread function from open-wc/lit-helpers * More informations here: https://open-wc.org/developing/lit-helpers.html */ -import {html, TemplateResult, directive, noChange } from 'lit-html'; + +import { + html, + TemplateResult, + noChange, + ChildPart, + AttributePart, + BooleanAttributePart, + EventPart, + PropertyPart, + ElementPart +} from 'lit'; + +import { directive, Directive, PartInfo, PartType } from 'lit/directive.js'; + +type SpreadPartType = + | ChildPart + | AttributePart + | BooleanAttributePart + | EventPart + | PropertyPart + | ElementPart; + const prevCache = new WeakMap(); -export const spread = directive((spreadData) => (part) => { - const prevData = prevCache.get(part); - if (prevData === spreadData) { - return; + +class SpreadDirective extends Directive { + spreadData: any; + + constructor(partInfo: PartInfo) { + super(partInfo); + this.spreadData = null; } - prevCache.set(part, spreadData); - - if (spreadData) { - for (const key in spreadData) { - const value = spreadData[key]; - if (value === noChange) continue; - - const prefix = key[0]; - const { element } = part.committer; - - if (prefix === '@') { - const prevHandler = prevData && prevData[key]; - if (!prevHandler || prevHandler !== value) { - const name = key.slice(1); - if (prevHandler) element.removeEventListener(name, prevHandler); - element.addEventListener(name, value); - } - continue; - } - if (prefix === '.') { - if (!prevData || prevData[key] !== value) { - element[key.slice(1)] = value; - } - continue; - } - if (prefix === '?') { - if (!prevData || prevData[key] !== value) { - const name = key.slice(1); - if (value) { - element.setAttribute(name, ''); - } else { - element.removeAttribute(name); - } - } - continue; - } - if (!prevData || prevData[key] !== value) { - if (value != null) { - element.setAttribute(key, String(value)); - } else { - element.removeAttribute(key); - } - } - } + + render(spreadData: any) { + this.spreadData = spreadData; + return noChange; } - if (prevData) { - for (const key in prevData) { - if (!spreadData || !(key in spreadData)) { + update(part: SpreadPartType, [spreadData]: any) { + const prevData = prevCache.get(part); + + if (prevData === spreadData) { + return noChange; + } + + let element; + prevCache.set(part, spreadData); + + if (part.type === PartType.ATTRIBUTE || part.type === PartType.PROPERTY) { + element = part.element; + } else { + console.warn('Unsupported part type or missing element, skipping update.'); + return noChange; + } + + if (spreadData) { + for (const key in spreadData) { + const value = spreadData[key]; + if (value === noChange) continue; + const prefix = key[0]; - const { element } = part.committer; + // Handle event listeners (e.g., @click) if (prefix === '@') { - element.removeEventListener(key.slice(1), prevData[key]); + const prevHandler = prevData && prevData[key]; + if (!prevHandler || prevHandler !== value) { + const name = key.slice(1); // Extract event name + if (prevHandler) element.removeEventListener(name, prevHandler); + element.addEventListener(name, value); + } continue; } + + // Handle properties (e.g., .value) if (prefix === '.') { - element[key.slice(1)] = undefined; + if (!prevData || prevData[key] !== value) { + element[key.slice(1)] = value; + } continue; } + + // Handle boolean attributes (e.g., ?disabled) if (prefix === '?') { - element.removeAttribute(key.slice(1)); + const attrName = key.slice(1); // Extract attribute name + if (!prevData || prevData[key] !== value) { + if (value) { + element.setAttribute(attrName, ''); + } else { + element.removeAttribute(attrName); + } + } continue; } - element.removeAttribute(key); + + // Handle regular attributes (e.g., class, id) + if (!prevData || prevData[key] !== value) { + if (value != null) { + element.setAttribute(key, String(value)); + } else { + element.removeAttribute(key); + } + } } } + + // Remove any old attributes or event listeners no longer in spreadData + if (prevData) { + for (const key in prevData) { + if (!spreadData || !(key in spreadData)) { + const prefix = key[0]; + + if (prefix === '@') { + element.removeEventListener(key.slice(1), prevData[key]); + continue; + } + if (prefix === '.') { + element[key.slice(1)] = undefined; + continue; + } + if (prefix === '?') { + element.removeAttribute(key.slice(1)); + continue; + } + element.removeAttribute(key); + } + } + } + + return noChange; } -}); +} +export const spread = directive(SpreadDirective); interface CachedNeedlessValue { - value: any; - index: number; + value: any; + index: number; } interface CachedTemplateStrings { - strings: string[]; - needlessValues: CachedNeedlessValue[]; + strings: TemplateStringsArray; + needlessValues: CachedNeedlessValue[]; } -function dropIndices(arr: any[], needlessValues: CachedNeedlessValue[]): any[] { - const newArr: any[] = []; - let j = 0; - - for (let i = 0, n = arr.length; i < n; ++i) { - if (needlessValues[j].index === i) { - ++j; - } else { - newArr.push(arr[i]); - } - } +const templateStringsCache = new WeakMap<TemplateStringsArray, CachedTemplateStrings[]>(); - return newArr; +function filterOutNeedlessValues(arr: any[], needlessValues: CachedNeedlessValue[]): any[] { + return arr.filter((_, i) => !needlessValues.some(nv => nv.index === i)); } -const templateStringsCache = new WeakMap<TemplateStringsArray, CachedTemplateStrings[]>(); - -// Convert dynamic tags to template strings -// example: <${'div'}>${'this is example'}</${'div'}> => <div>${'this is example'}</div> export function preHTML(strings: TemplateStringsArray, ...values: any[]): TemplateResult { - // check cache !important return equal link at first argument - let cachedStrings = templateStringsCache.get(strings) as CachedTemplateStrings[]; - if (cachedStrings) { - for (let i = 0, n = cachedStrings.length; i < n; ++i) { - const needlessValues = cachedStrings[i].needlessValues; - let isSame = true; - for (let ii = 0, nn = needlessValues.length; ii < nn; ++ii) { - if (values[needlessValues[ii].index] !== needlessValues[ii].value) { - isSame = false; - break; - } - } + let cachedStrings = templateStringsCache.get(strings); - if (isSame) { - return html( - cachedStrings[i].strings as any, - ...dropIndices(values, needlessValues) - ); - } - } + if (cachedStrings) { + for (let cached of cachedStrings) { + const { needlessValues } = cached; + const isSame = needlessValues.every(nv => values[nv.index] === nv.value); + + if (isSame) { + // Return cached template result if values match + return html(cached.strings, ...filterOutNeedlessValues(values, needlessValues)); + } } + } - const needlessValues: CachedNeedlessValue[] = []; - const newStrings: string[] = []; - - let str: string; - for (let i = 0, n = strings.length; i < n; ++i) { - str = strings[i]; - - while ( - str[str.length - 1] === '<' // open tag - || (str[str.length - 2] === '<' && str[str.length - 1] === '/') // close tag - ) { - needlessValues.push({ - value: values[i], - index: i, - }); - str += values[i] + strings[++i]; - } + // No match found, so we need to create new template strings and cache them + const needlessValues: CachedNeedlessValue[] = []; + const newStrings: string[] = []; - newStrings.push(str); - } + for (let i = 0; i < strings.length; i++) { + let str = strings[i]; - if (!cachedStrings) { - cachedStrings = []; - templateStringsCache.set(strings, cachedStrings); + while (str.endsWith('<') || (str.length >= 2 && str.endsWith('</'))) { + needlessValues.push({ value: values[i], index: i }); + str += values[i] + strings[++i]; } - cachedStrings.push({ - strings: newStrings, - needlessValues, - }); + newStrings.push(str); + } + + // Convert newStrings back to TemplateStringsArray type + const finalStrings = Object.assign([...newStrings], { raw: strings.raw }); + + if (!cachedStrings) { + cachedStrings = []; + templateStringsCache.set(strings, cachedStrings); + } + + cachedStrings.push({ + strings: finalStrings as TemplateStringsArray, + needlessValues, + }); - return html(newStrings as any, ...dropIndices(values, needlessValues)); + return html(finalStrings as TemplateStringsArray, ...filterOutNeedlessValues(values, needlessValues)); } \ No newline at end of file diff --git a/src/mixins/counterMixin.ts b/src/mixins/counterMixin.ts index 465a396e..0bfcc4ae 100644 --- a/src/mixins/counterMixin.ts +++ b/src/mixins/counterMixin.ts @@ -1,5 +1,5 @@ -import { html } from 'lit-html'; -import { unsafeHTML } from 'lit-html/directives/unsafe-html'; +import { html } from 'lit'; +import { unsafeHTML } from 'lit/directives/unsafe-html.js'; import { evalTemplateString } from '../libs/helpers'; import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; diff --git a/src/mixins/listMixin.ts b/src/mixins/listMixin.ts index 3e6ae80c..40180914 100644 --- a/src/mixins/listMixin.ts +++ b/src/mixins/listMixin.ts @@ -1,6 +1,6 @@ -import { html, render } from 'lit-html'; +import { html, render } from 'lit'; import { preHTML } from '../libs/lit-helpers'; -import { ifDefined } from 'lit-html/directives/if-defined'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const ListMixin = { @@ -135,9 +135,7 @@ const ListMixin = { context: string, ) { if (this.emptyWidget) { - const emptyWidgetTemplate = preHTML` - <${this.emptyWidget} value=${ifDefined(this.emptyValue)}></${this.emptyWidget}> - ` + const emptyWidgetTemplate = preHTML`<${this.emptyWidget} value=${ifDefined(this.emptyValue)}></${this.emptyWidget}>` if (!this.emptyWrapper) { this.emptyWrapper = document.createElement('span') this.element.appendChild(this.emptyWrapper) diff --git a/src/mixins/paginateMixin.ts b/src/mixins/paginateMixin.ts index 5a93feb2..105ab4e2 100644 --- a/src/mixins/paginateMixin.ts +++ b/src/mixins/paginateMixin.ts @@ -1,4 +1,4 @@ -import { html, TemplateResult } from "lit-html"; +import { html, TemplateResult } from "lit"; import { PostProcessorRegistry } from "../libs/PostProcessorRegistry"; const PaginateMixin = { diff --git a/src/mixins/serverPaginationMixin.ts b/src/mixins/serverPaginationMixin.ts index 235fd422..815145ca 100644 --- a/src/mixins/serverPaginationMixin.ts +++ b/src/mixins/serverPaginationMixin.ts @@ -1,4 +1,4 @@ -import { html, render } from "lit-html"; +import { html, render } from "lit"; const ServerPaginationMixin = { name: 'server-pagination-mixin', diff --git a/src/mixins/validationMixin.ts b/src/mixins/validationMixin.ts index cd56edff..9a5fa2ec 100644 --- a/src/mixins/validationMixin.ts +++ b/src/mixins/validationMixin.ts @@ -1,6 +1,6 @@ import dialogPolyfill from 'dialog-polyfill' -import { html } from 'lit-html'; -import { ifDefined } from 'lit-html/directives/if-defined'; +import { html } from 'lit'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { uniqID } from '../libs/helpers'; import { TranslationMixin } from './translationMixin'; import { preHTML } from '../libs/lit-helpers'; @@ -69,11 +69,8 @@ const ValidationMixin = { } return html` <dialog id="${this.dialogID}"> - ${this.confirmationWidget ? preHTML` - <${this.confirmationWidget} value=${this.resourceId}></${this.confirmationWidget}> - ` : html` - <p>${this.confirmationMessage || this.t("validation.message")}</p> - `} + ${this.confirmationWidget ? preHTML`<${this.confirmationWidget} value=${this.resourceId}></${this.confirmationWidget}>` : + html`<p>${this.confirmationMessage || this.t("validation.message")}</p>`} <div> <button @click=${confirmChoice} diff --git a/src/mixins/widgetMixin.ts b/src/mixins/widgetMixin.ts index 01fd96fe..858be17d 100644 --- a/src/mixins/widgetMixin.ts +++ b/src/mixins/widgetMixin.ts @@ -2,8 +2,8 @@ import { spread, preHTML } from '../libs/lit-helpers'; import { parseFieldsString, findClosingBracketMatchIndex } from '../libs/helpers'; import { newWidgetFactory } from '../new-widgets/new-widget-factory'; import { WidgetInterface, WidgetType, Resource } from './interfaces'; -import { html, render, TemplateResult } from 'lit-html'; -import { ifDefined } from 'lit-html/directives/if-defined'; +import { html, render, TemplateResult } from 'lit'; +import { ifDefined } from 'lit/directives/if-defined.js'; const WidgetMixin = { name: 'widget-mixin', @@ -312,17 +312,12 @@ const WidgetMixin = { const escapedField = this.getEscapedField(field); const widgetMeta = this.multiple(escapedField) || this.getWidget(escapedField); let tagName = widgetMeta.tagName; - let widgetTemplate = html``; + let widgetTemplate: TemplateResult = html``; // Set attributes let value = await this.getValue(field, currentResource); if (widgetMeta.type === WidgetType.NATIVE) { // native widget (ie: h1) - widgetTemplate = preHTML` - <${tagName} - name="${ifDefined(attributes.name)}" - class="${ifDefined(attributes.class)}" - >${value}</${tagName}> - `; + widgetTemplate = preHTML`<${tagName} name="${ifDefined(attributes.name)}" class="${ifDefined(attributes.class)}">${value}</${tagName}>`; } else { // custom widget (ie: solid-display-value) // Check if value is defined, and if the default widget is needed if ((value === null || value === '') && this.element.hasAttribute('default-widget-' + field)) { @@ -417,9 +412,7 @@ const WidgetMixin = { return widget; }, createString(value: string): TemplateResult { - return html` - <span>${value.slice(1, -1).replace(/\\(['"])/g, '$1')}</span> - `; + return html`<span>${value.slice(1, -1).replace(/\\(['"])/g, '$1')}</span>`; }, /** * Returns field name without starting "@" diff --git a/src/new-widgets/baseWidgetMixin.ts b/src/new-widgets/baseWidgetMixin.ts index 7bdd8a2f..eea880ef 100644 --- a/src/new-widgets/baseWidgetMixin.ts +++ b/src/new-widgets/baseWidgetMixin.ts @@ -1,7 +1,7 @@ import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; import type { Template } from './interfaces'; -import {render} from 'lit-html'; +import {render} from 'lit'; const BaseWidgetMixin = { name: 'widget-mixin', diff --git a/src/new-widgets/templateAdditionMixins/addableMixin.ts b/src/new-widgets/templateAdditionMixins/addableMixin.ts index 81916c9e..edd6c3f8 100644 --- a/src/new-widgets/templateAdditionMixins/addableMixin.ts +++ b/src/new-widgets/templateAdditionMixins/addableMixin.ts @@ -1,7 +1,7 @@ import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; import { spread } from '../../libs/lit-helpers'; -import { html } from 'lit-html'; +import { html } from 'lit'; const AddableMixin = { name: 'addable-mixin', diff --git a/src/new-widgets/templateAdditionMixins/labelLastMixin.ts b/src/new-widgets/templateAdditionMixins/labelLastMixin.ts index 83b5b040..f1136d4b 100644 --- a/src/new-widgets/templateAdditionMixins/labelLastMixin.ts +++ b/src/new-widgets/templateAdditionMixins/labelLastMixin.ts @@ -1,4 +1,4 @@ -import { html } from 'lit-html'; +import { html } from 'lit'; import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const LabelLastMixin = { @@ -7,10 +7,7 @@ const LabelLastMixin = { this.listTemplateAdditions.attach(this.addLabelLast.bind(this), "LabelLastMixin:addLabelLast"); }, addLabelLast(template, listTemplateAdditions: PostProcessorRegistry) { - const newTemplate = html` - ${template} - <label>${this.label || this.name}</label> - `; + const newTemplate = html`${template}<label>${this.label || this.name}</label>`; const nextProcessor = listTemplateAdditions.shift(); if (nextProcessor) nextProcessor(newTemplate, listTemplateAdditions); diff --git a/src/new-widgets/templateAdditionMixins/labelMixin.ts b/src/new-widgets/templateAdditionMixins/labelMixin.ts index c00fa01d..ac938f54 100644 --- a/src/new-widgets/templateAdditionMixins/labelMixin.ts +++ b/src/new-widgets/templateAdditionMixins/labelMixin.ts @@ -1,4 +1,4 @@ -import { html } from 'lit-html'; +import { html } from 'lit'; import { uniqID } from '../../libs/helpers'; import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; @@ -9,10 +9,7 @@ const LabelMixin = { this.listTemplateAdditions.attach(this.addLabel.bind(this), "LabelMixin:addLabel"); }, addLabel(template, listTemplateAdditions: PostProcessorRegistry) { - const newTemplate = html` - <label for="${this.listAttributes['id']}">${this.label || this.name}</label> - ${template} - `; + const newTemplate = html`<label for="${this.listAttributes['id']}">${this.label || this.name}</label>${template}`; const nextProcessor = listTemplateAdditions.shift(); if (nextProcessor) nextProcessor(newTemplate, listTemplateAdditions); diff --git a/src/new-widgets/templates/defaultTemplatesDirectory.ts b/src/new-widgets/templates/defaultTemplatesDirectory.ts index 53cd4993..9d64d2a0 100644 --- a/src/new-widgets/templates/defaultTemplatesDirectory.ts +++ b/src/new-widgets/templates/defaultTemplatesDirectory.ts @@ -1,5 +1,5 @@ -import { html } from 'lit-html'; -import { ifDefined } from 'lit-html/directives/if-defined'; +import { html } from 'lit'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { LinkTextMixin } from '../templatesDependencies/linkTextMixin'; export const defaultTemplates = { diff --git a/src/new-widgets/templates/displayTemplatesDirectory.ts b/src/new-widgets/templates/displayTemplatesDirectory.ts index f815bb59..7ca569f2 100644 --- a/src/new-widgets/templates/displayTemplatesDirectory.ts +++ b/src/new-widgets/templates/displayTemplatesDirectory.ts @@ -2,8 +2,8 @@ import { EditableMixin } from '../templatesDependencies/editableMixin'; import { AltMixin } from '../templatesDependencies/altMixin'; import { LinkTextMixin } from '../templatesDependencies/linkTextMixin'; -import { html } from 'lit-html'; -import { ifDefined } from 'lit-html/directives/if-defined'; +import { html } from 'lit'; +import { ifDefined } from 'lit/directives/if-defined.js'; export const displayTemplates = { value: { @@ -11,14 +11,7 @@ export const displayTemplates = { dependencies: [] }, div: { - template: (value: string, attributes: any) => html` - <div - name=${ifDefined(attributes.name)} - ?data-editable=${attributes.editable} - > - ${value} - </div> - `, + template: (value: string, attributes: any) => html`<div name=${ifDefined(attributes.name)} ?data-editable=${attributes.editable}>${value}</div>`, dependencies: [ EditableMixin ] }, link: { @@ -48,9 +41,7 @@ export const displayTemplates = { dependencies: [AltMixin] }, boolean: { - template: (value: string, attributes: any) => html` - ${value === 'true' ? html`<label>${attributes.label || attributes.name || ''}</label>` : ''} - `, + template: (value: string, attributes: any) => html`${value === 'true' ? html`<label>${attributes.label || attributes.name || ''}</label>` : ''}`, dependencies: [] }, } diff --git a/src/new-widgets/templates/formTemplatesDirectory.ts b/src/new-widgets/templates/formTemplatesDirectory.ts index 74f334fb..abc03ecd 100644 --- a/src/new-widgets/templates/formTemplatesDirectory.ts +++ b/src/new-widgets/templates/formTemplatesDirectory.ts @@ -15,8 +15,8 @@ import { PatternMixin } from '../templatesDependencies/patternMixin'; import { FormStepMixin } from '../templatesDependencies/formStepMixin'; import { FormLengthMixin } from '../templatesDependencies/formLengthMixin'; -import { html } from 'lit-html'; -import { ifDefined } from 'lit-html/directives/if-defined'; +import { html } from 'lit'; +import { ifDefined } from 'lit/directives/if-defined.js'; export const formTemplates = { text: { diff --git a/src/new-widgets/templates/groupTemplatesDirectory.ts b/src/new-widgets/templates/groupTemplatesDirectory.ts index bb88ebd1..511e5ae9 100644 --- a/src/new-widgets/templates/groupTemplatesDirectory.ts +++ b/src/new-widgets/templates/groupTemplatesDirectory.ts @@ -1,12 +1,9 @@ -import { html } from 'lit-html'; +import { html } from 'lit'; import { SetMixin } from '../templatesDependencies/setMixin'; export const groupTemplates = { default: { - template: (value: string) => html` - <span>${value}</span> - <div data-content></div> - `, + template: (value: string) => html`<span>${value}</span><div data-content></div>`, dependencies: [SetMixin] }, } \ No newline at end of file diff --git a/src/new-widgets/templates/setTemplatesDirectory.ts b/src/new-widgets/templates/setTemplatesDirectory.ts index 61ae761b..0e0580b0 100644 --- a/src/new-widgets/templates/setTemplatesDirectory.ts +++ b/src/new-widgets/templates/setTemplatesDirectory.ts @@ -1,4 +1,4 @@ -import { html } from 'lit-html'; +import { html } from 'lit'; import { SetMixin } from '../templatesDependencies/setMixin'; export const setTemplates = { diff --git a/src/new-widgets/templatesDependencies/editableMixin.ts b/src/new-widgets/templatesDependencies/editableMixin.ts index d5e87c0a..c0d9bba5 100644 --- a/src/new-widgets/templatesDependencies/editableMixin.ts +++ b/src/new-widgets/templatesDependencies/editableMixin.ts @@ -1,7 +1,7 @@ import { StoreMixin } from '../../mixins/storeMixin'; import { store } from '../../libs/store/store'; -import { html } from 'lit-html'; +import { html } from 'lit'; import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const EditableMixin = { diff --git a/src/new-widgets/valueTransformationMixins/markdownMixin.ts b/src/new-widgets/valueTransformationMixins/markdownMixin.ts index de847e64..401f93f5 100644 --- a/src/new-widgets/valueTransformationMixins/markdownMixin.ts +++ b/src/new-widgets/valueTransformationMixins/markdownMixin.ts @@ -1,4 +1,4 @@ -import { unsafeHTML } from 'lit-html/directives/unsafe-html'; +import { unsafeHTML } from 'lit/directives/unsafe-html.js'; import markdownit from 'markdown-it'; import mila from 'markdown-it-link-attributes'; diff --git a/src/new-widgets/valueTransformationMixins/multilineMixin.ts b/src/new-widgets/valueTransformationMixins/multilineMixin.ts index ff58b82b..6e80e03a 100644 --- a/src/new-widgets/valueTransformationMixins/multilineMixin.ts +++ b/src/new-widgets/valueTransformationMixins/multilineMixin.ts @@ -1,4 +1,4 @@ -import { unsafeHTML } from 'lit-html/directives/unsafe-html'; +import { unsafeHTML } from 'lit/directives/unsafe-html.js'; import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const MultilineMixin = { diff --git a/src/new-widgets/valueTransformationMixins/oembedMixin.ts b/src/new-widgets/valueTransformationMixins/oembedMixin.ts index 04493de0..8bda9c17 100644 --- a/src/new-widgets/valueTransformationMixins/oembedMixin.ts +++ b/src/new-widgets/valueTransformationMixins/oembedMixin.ts @@ -1,4 +1,4 @@ -import { unsafeHTML } from 'lit-html/directives/unsafe-html'; +import { unsafeHTML } from 'lit/directives/unsafe-html.js'; import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const OembedMixin = { -- GitLab From 33a6dfc093ebc221d3cbe9181f2e8fcc5a62497d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 11 Oct 2024 20:17:10 +0200 Subject: [PATCH 11/66] use asyncQuerySelector --- .../callbackMixins/autocompletionMixin.ts | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/new-widgets/callbackMixins/autocompletionMixin.ts b/src/new-widgets/callbackMixins/autocompletionMixin.ts index ca26673b..8ab41baa 100644 --- a/src/new-widgets/callbackMixins/autocompletionMixin.ts +++ b/src/new-widgets/callbackMixins/autocompletionMixin.ts @@ -1,4 +1,4 @@ -import { fuzzyCompare, importInlineCSS } from '../../libs/helpers'; +import { asyncQuerySelector, fuzzyCompare, importInlineCSS } from '../../libs/helpers'; import SlimSelect from 'slim-select'; import { TranslationMixin } from '../../mixins/translationMixin'; import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; @@ -39,23 +39,7 @@ const AutocompletionMixin = { }, addCallback(value: string, listCallbacks: PostProcessorRegistry) { if (this.slimSelect) return; - let select = this.element.querySelector('select'); - if (select) { - this.initSlimSelect(select); - } else { - // if no select available, wait for one and init slimSelect - new MutationObserver((_m, observer) => { - const select = this.element.querySelector('select'); - if (select) { - this.initSlimSelect(select); - observer.disconnect(); // then disconnect mutationObserver - } - }).observe(this.element, { - childList: true, - characterData: true, - subtree: true, - }); - } + asyncQuerySelector('select', this.element).then(select => this.initSlimSelect(select)) const nextProcessor = listCallbacks.shift(); if (nextProcessor) nextProcessor(value, listCallbacks); }, -- GitLab From f237682f2e91470444dcc68449b495fb7a35f91c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 11 Oct 2024 22:20:18 +0200 Subject: [PATCH 12/66] update: fix `examples/solid-form.html` --- examples/solid-form.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/solid-form.html b/examples/solid-form.html index 696c9fb6..b13ab928 100644 --- a/examples/solid-form.html +++ b/examples/solid-form.html @@ -120,7 +120,7 @@ data-src="/examples/data/list/event-1.jsonld" fields="contact" widget-contact="solid-form-dropdown-autocompletion" - range-contact="data/list/users.jsonld" + range-contact="/examples/data/list/skills.jsonld" ></solid-form> <h2>Multiple skills</h2> <solid-form -- GitLab From b0a4f4c5c90bc09103c64eacdc0bf784184d7ff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 11 Oct 2024 22:36:15 +0200 Subject: [PATCH 13/66] update: add examples/solid-form-auto-complete.html --- examples/solid-form-auto-complete.html | 28 ++++++++++++++++++++++++++ index.html | 1 + 2 files changed, 29 insertions(+) create mode 100644 examples/solid-form-auto-complete.html diff --git a/examples/solid-form-auto-complete.html b/examples/solid-form-auto-complete.html new file mode 100644 index 00000000..e5c407b0 --- /dev/null +++ b/examples/solid-form-auto-complete.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="UTF-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>SIB test: solid-form auto-complete</title> + <script type="module" src="../dist/index.js"></script> + <link rel="stylesheet" href="styles.css" /> + </head> + + <body> + <h1>Auto complete</h1> + <h2>Single skill</h2> + <solid-form + data-src="/examples/data/list/user-1.jsonld" + fields="skills" + widget-skills="solid-form-dropdown-autocompletion" + range-skills="/examples/data/list/skills.jsonld" + ></solid-form> + <h2>Multiple skills</h2> + <solid-form + data-src="/examples/data/list/user-1.jsonld" + fields="skills" + range-skills="/examples/data/list/skills.jsonld" + multiple-skills="solid-form-multipleselect-autocompletion" + ></solid-form> + </body> +</html> diff --git a/index.html b/index.html index 71adacda..96fb5be9 100644 --- a/index.html +++ b/index.html @@ -46,6 +46,7 @@ <li><a href="./examples/nested-form.html">nested-form</a></li> <li><a href="./examples/validation.html">solid-form + confirm or dialog popup</a></li> <li><a href="./examples/auto-range.html">auto-range</a></li> + <li><a href="./examples/solid-form-auto-complete.html">solid-form auto-complete</a></li> </ul> </li> <li> -- GitLab From 450d3336c97836e2e1e80ea49e17d4968ed72502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Sat, 12 Oct 2024 09:31:22 +0200 Subject: [PATCH 14/66] update: improve slimSelect type --- src/new-widgets/callbackMixins/autocompletionMixin.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/new-widgets/callbackMixins/autocompletionMixin.ts b/src/new-widgets/callbackMixins/autocompletionMixin.ts index 8ab41baa..28c857a1 100644 --- a/src/new-widgets/callbackMixins/autocompletionMixin.ts +++ b/src/new-widgets/callbackMixins/autocompletionMixin.ts @@ -47,7 +47,8 @@ const AutocompletionMixin = { const slimSelect = new SlimSelect({ select }); this.slimSelect = slimSelect; select.addEventListener('change', () => { - this.slimSelect.render(); + const slimSelect: SlimSelect = this.slimSelect; + slimSelect.render(); this.element.dispatchEvent(new Event('input', { bubbles: true })); }); this.element.addEventListener('input', (e:Event) => { @@ -60,14 +61,16 @@ const AutocompletionMixin = { // when data changes, re-build slimSelect if (this.mutationObserver) this.mutationObserver.disconnect(); this.mutationObserver = new MutationObserver(() => { - this.slimSelect.destroy(); - this.slimSelect = new SlimSelect({ + let slimSelect: SlimSelect = this.slimSelect; + slimSelect.destroy(); + slimSelect = new SlimSelect({ select, placeholder: this.placeholder || this.t("autocompletion.placeholder"), searchText: this.searchText || this.t("autocompletion.searchText"), searchPlaceholder: this.searchPlaceholder || this.t("autocompletion.searchPlaceholder"), searchFilter: (option, filterValue) => fuzzyCompare(option.text, filterValue), }); + this.slimSelect = slimSelect; }).observe(select, { childList: true, characterData: true, -- GitLab From 94bd345854cc63d532c99bea536dc25bc719495b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Sat, 12 Oct 2024 10:24:55 +0200 Subject: [PATCH 15/66] update: use sourcemap on watch --- package.json | 2 +- vite.config.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 2e14ae8c..42d49d70 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ ], "scripts": { "build": "vite build", - "watch": "vite build --watch", + "watch": "vite build --watch --sourcemap 'inline'", "serve": "node --watch server.js", "check-types": "tsc", "test": "node server.js --test", diff --git a/vite.config.ts b/vite.config.ts index 3447be02..deb78a86 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -23,5 +23,6 @@ export default defineConfig({ }, outDir: 'dist', minify: false, + reportCompressedSize:false, }, }); -- GitLab From 92a7689040cfa3769d108bf51899f351d460731a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Sat, 12 Oct 2024 12:38:49 +0200 Subject: [PATCH 16/66] update: SlimSelect 2 --- package-lock.json | 12 +++++------- package.json | 2 +- .../callbackMixins/autocompletionMixin.ts | 17 +++++++++++------ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0d2b8077..7668eaaf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,7 +39,7 @@ "quill": "^2.0.2", "quill-delta-to-markdown": "^0.6.0", "semver": "7.6.3", - "slim-select": "^1.27.1", + "slim-select": "^2.9.2", "tui-calendar": "^1.15.3", "typescript": "^5.6.2", "vite": "^5.4.8" @@ -4184,13 +4184,11 @@ "dev": true }, "node_modules/slim-select": { - "version": "1.27.1", - "resolved": "https://registry.npmjs.org/slim-select/-/slim-select-1.27.1.tgz", - "integrity": "sha512-LvJ02cKKk6/jSHIcQv7dZwkQSXHLCVQR3v3lo8RJUssUUcmKPkpBmTpQ8au8KSMkxwca9+yeg+dO0iHAaVr5Aw==", + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/slim-select/-/slim-select-2.9.2.tgz", + "integrity": "sha512-3Kxgj7Nk7sHHEu8Xzq70pkNNNdKmOr3OwKOjqSzcGeJ9j2hCOxIvIdYcAqKUM1eRnl+3ycKKK/YrzsjxrxAoZg==", "dev": true, - "engines": { - "node": ">=8" - } + "license": "MIT" }, "node_modules/source-map": { "version": "0.6.1", diff --git a/package.json b/package.json index 42d49d70..70bb0830 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "quill": "^2.0.2", "quill-delta-to-markdown": "^0.6.0", "semver": "7.6.3", - "slim-select": "^1.27.1", + "slim-select": "^2.9.2", "tui-calendar": "^1.15.3", "typescript": "^5.6.2", "vite": "^5.4.8" diff --git a/src/new-widgets/callbackMixins/autocompletionMixin.ts b/src/new-widgets/callbackMixins/autocompletionMixin.ts index 28c857a1..14f4d4d4 100644 --- a/src/new-widgets/callbackMixins/autocompletionMixin.ts +++ b/src/new-widgets/callbackMixins/autocompletionMixin.ts @@ -27,7 +27,8 @@ const AutocompletionMixin = { mutationObserver: null }, created() { - importInlineCSS('slimselect', () => import('./slimselect.css?inline')) + importInlineCSS('slimselect-base', () => import('slim-select/styles?inline')); + importInlineCSS('slimselect-local', () => import('./slimselect.css?inline')); this.slimSelect = null; this.addToAttributes(true, 'autocomplete'); @@ -48,7 +49,7 @@ const AutocompletionMixin = { this.slimSelect = slimSelect; select.addEventListener('change', () => { const slimSelect: SlimSelect = this.slimSelect; - slimSelect.render(); + // slimSelect.render(); this.element.dispatchEvent(new Event('input', { bubbles: true })); }); this.element.addEventListener('input', (e:Event) => { @@ -65,10 +66,14 @@ const AutocompletionMixin = { slimSelect.destroy(); slimSelect = new SlimSelect({ select, - placeholder: this.placeholder || this.t("autocompletion.placeholder"), - searchText: this.searchText || this.t("autocompletion.searchText"), - searchPlaceholder: this.searchPlaceholder || this.t("autocompletion.searchPlaceholder"), - searchFilter: (option, filterValue) => fuzzyCompare(option.text, filterValue), + settings: { + placeholderText: this.placeholder || this.t("autocompletion.placeholder"), + searchText: this.searchText || this.t("autocompletion.searchText"), + searchPlaceholder: this.searchPlaceholder || this.t("autocompletion.searchPlaceholder"), + }, + events: { + searchFilter: (option, filterValue) => fuzzyCompare(option.text, filterValue), + }, }); this.slimSelect = slimSelect; }).observe(select, { -- GitLab From ca4efb181fa440b57539575d0d35a71be0c573d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Sat, 12 Oct 2024 13:04:17 +0200 Subject: [PATCH 17/66] update: quickfix SlimSelect bug --- src/new-widgets/callbackMixins/autocompletionMixin.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/new-widgets/callbackMixins/autocompletionMixin.ts b/src/new-widgets/callbackMixins/autocompletionMixin.ts index 14f4d4d4..c8780925 100644 --- a/src/new-widgets/callbackMixins/autocompletionMixin.ts +++ b/src/new-widgets/callbackMixins/autocompletionMixin.ts @@ -45,6 +45,11 @@ const AutocompletionMixin = { if (nextProcessor) nextProcessor(value, listCallbacks); }, initSlimSelect(select: Element) { + const change = (event: Event) => event.stopPropagation(); + select.addEventListener("change", change, { capture: true }); + setTimeout(() => { + select.removeEventListener("change", change, { capture: true }); + }, 750); const slimSelect = new SlimSelect({ select }); this.slimSelect = slimSelect; select.addEventListener('change', () => { -- GitLab From 7ab09ed37f6f8e0afafeaeefbfc493022f1e6607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Sat, 12 Oct 2024 13:07:19 +0200 Subject: [PATCH 18/66] update: remove usless SlimSelect listeners --- src/new-widgets/callbackMixins/autocompletionMixin.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/new-widgets/callbackMixins/autocompletionMixin.ts b/src/new-widgets/callbackMixins/autocompletionMixin.ts index c8780925..6d657065 100644 --- a/src/new-widgets/callbackMixins/autocompletionMixin.ts +++ b/src/new-widgets/callbackMixins/autocompletionMixin.ts @@ -52,11 +52,6 @@ const AutocompletionMixin = { }, 750); const slimSelect = new SlimSelect({ select }); this.slimSelect = slimSelect; - select.addEventListener('change', () => { - const slimSelect: SlimSelect = this.slimSelect; - // slimSelect.render(); - this.element.dispatchEvent(new Event('input', { bubbles: true })); - }); this.element.addEventListener('input', (e:Event) => { if(e.target !== this.element) { // avoid update search result when search in slimSelect suggestions -- GitLab From 0d3930e7c44df5fb46f53b2be4c8f304975b59e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Sat, 12 Oct 2024 20:08:39 +0200 Subject: [PATCH 19/66] update: fix translation tests --- cypress/e2e/e2e/translation.cy.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cypress/e2e/e2e/translation.cy.ts b/cypress/e2e/e2e/translation.cy.ts index 440a9081..8ddce2e1 100644 --- a/cypress/e2e/e2e/translation.cy.ts +++ b/cypress/e2e/e2e/translation.cy.ts @@ -34,12 +34,12 @@ describe('translation', function () { // french in autompletion multipleselect cy.get('solid-form-search#translation-autocomp') - .find('.ss-disabled').should('contain', 'Sélectionner une valeur') + .find('.ss-placeholder').should('contain', 'Sélectionner une valeur') .click(); - cy.get('solid-form-search#translation-autocomp') + cy.get('.ss-content') .find('.ss-search').children().should('have.attr', 'placeholder', 'Rechercher') .wait(200).type('00'); - cy.get('solid-form-search#translation-autocomp') + cy.get('.ss-content') .find('.ss-list').children().contains('Aucun résultat') }); @@ -69,12 +69,12 @@ describe('translation', function () { // english in autompletion multipleselect cy.get('solid-form-search#translation-autocomp') - .find('.ss-disabled').should('contain', 'Select a value') + .find('.ss-placeholder').should('contain', 'Select a value') .click(); - cy.get('solid-form-search#translation-autocomp') + cy.get('.ss-content') .find('.ss-search').children().should('have.attr', 'placeholder', 'Search') .wait(200).type('00'); - cy.get('solid-form-search#translation-autocomp') + cy.get('.ss-content') .find('.ss-list').children().contains('No result') }); -- GitLab From 02d21dcd2592a046f47f55b9009c8ac712e10ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Mon, 14 Oct 2024 11:45:53 +0200 Subject: [PATCH 20/66] wait for `select>option` --- .../callbackMixins/autocompletionMixin.ts | 46 ++++++------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/src/new-widgets/callbackMixins/autocompletionMixin.ts b/src/new-widgets/callbackMixins/autocompletionMixin.ts index 6d657065..32296f03 100644 --- a/src/new-widgets/callbackMixins/autocompletionMixin.ts +++ b/src/new-widgets/callbackMixins/autocompletionMixin.ts @@ -40,17 +40,24 @@ const AutocompletionMixin = { }, addCallback(value: string, listCallbacks: PostProcessorRegistry) { if (this.slimSelect) return; - asyncQuerySelector('select', this.element).then(select => this.initSlimSelect(select)) + asyncQuerySelector('select:has(option)', this.element).then(select => { + this.initSlimSelect(select); + }) const nextProcessor = listCallbacks.shift(); if (nextProcessor) nextProcessor(value, listCallbacks); }, - initSlimSelect(select: Element) { - const change = (event: Event) => event.stopPropagation(); - select.addEventListener("change", change, { capture: true }); - setTimeout(() => { - select.removeEventListener("change", change, { capture: true }); - }, 750); - const slimSelect = new SlimSelect({ select }); + async initSlimSelect(select: Element) { + const slimSelect = new SlimSelect({ + select, + settings: { + placeholderText: this.placeholder || this.t("autocompletion.placeholder"), + searchText: this.searchText || this.t("autocompletion.searchText"), + searchPlaceholder: this.searchPlaceholder || this.t("autocompletion.searchPlaceholder"), + }, + events: { + searchFilter: (option, filterValue) => fuzzyCompare(option.text, filterValue), + }, + }); this.slimSelect = slimSelect; this.element.addEventListener('input', (e:Event) => { if(e.target !== this.element) { @@ -58,29 +65,6 @@ const AutocompletionMixin = { e.stopPropagation(); } }); - - // when data changes, re-build slimSelect - if (this.mutationObserver) this.mutationObserver.disconnect(); - this.mutationObserver = new MutationObserver(() => { - let slimSelect: SlimSelect = this.slimSelect; - slimSelect.destroy(); - slimSelect = new SlimSelect({ - select, - settings: { - placeholderText: this.placeholder || this.t("autocompletion.placeholder"), - searchText: this.searchText || this.t("autocompletion.searchText"), - searchPlaceholder: this.searchPlaceholder || this.t("autocompletion.searchPlaceholder"), - }, - events: { - searchFilter: (option, filterValue) => fuzzyCompare(option.text, filterValue), - }, - }); - this.slimSelect = slimSelect; - }).observe(select, { - childList: true, - characterData: true, - subtree: true, - }); }, }; -- GitLab From 9d901e44ebc973d7fed8343347c3132b82ec6157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Mon, 14 Oct 2024 11:47:11 +0200 Subject: [PATCH 21/66] update: add example with newWidgetFactory --- examples/solid-form-auto-complete.html | 14 ++++++++++++++ .../callbackMixins/autocompletionMixin.ts | 1 + 2 files changed, 15 insertions(+) diff --git a/examples/solid-form-auto-complete.html b/examples/solid-form-auto-complete.html index e5c407b0..3589279c 100644 --- a/examples/solid-form-auto-complete.html +++ b/examples/solid-form-auto-complete.html @@ -24,5 +24,19 @@ range-skills="/examples/data/list/skills.jsonld" multiple-skills="solid-form-multipleselect-autocompletion" ></solid-form> + + <h2>New Widget Factory</h2> + <script type="module"> + import { newWidgetFactory } from '../../dist/index.js'; + + newWidgetFactory('solid-form-dropdown-autocompletion-placeholder'); + </script> + + <solid-form-dropdown-autocompletion-placeholder + id="test9" + name="test9" + search-placeholder="Skills :" + range="/examples/data/list/skills.jsonld" + ></solid-form-dropdown-autocompletion-placeholder> </body> </html> diff --git a/src/new-widgets/callbackMixins/autocompletionMixin.ts b/src/new-widgets/callbackMixins/autocompletionMixin.ts index 32296f03..64f69a9a 100644 --- a/src/new-widgets/callbackMixins/autocompletionMixin.ts +++ b/src/new-widgets/callbackMixins/autocompletionMixin.ts @@ -47,6 +47,7 @@ const AutocompletionMixin = { if (nextProcessor) nextProcessor(value, listCallbacks); }, async initSlimSelect(select: Element) { + await new Promise(resolve => setTimeout(resolve, 500)) const slimSelect = new SlimSelect({ select, settings: { -- GitLab From e9832c57d75dbe66c5bf3e0e1576b8d7ff53f4b6 Mon Sep 17 00:00:00 2001 From: Anastasia Kryukova <anastasia.kryukova@protonmail.com> Date: Tue, 15 Oct 2024 15:38:50 +0200 Subject: [PATCH 22/66] fix: issue of .ss-search and .ss-list --- cypress/e2e/e2e/widgets-form.cy.ts | 5 +++-- src/new-widgets/callbackMixins/autocompletionMixin.ts | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/e2e/widgets-form.cy.ts b/cypress/e2e/e2e/widgets-form.cy.ts index e4989330..7440f7d0 100644 --- a/cypress/e2e/e2e/widgets-form.cy.ts +++ b/cypress/e2e/e2e/widgets-form.cy.ts @@ -347,11 +347,12 @@ describe('form widgets', { testIsolation: false }, function () { .children() .should('have.length', 8); cy.get('solid-form-dropdown-autocompletion-placeholder > div') - .find('div .ss-search').children() + .find('div.ss-search').children() .eq(0) .should('have.attr', 'placeholder', 'Skills :'); cy.get('solid-form-dropdown-autocompletion-placeholder > div') - .find('div .ss-list') + .find('div.ss-list') + .first() .children() .should('have.length', 8) .should('not.contain', 'Skills :'); diff --git a/src/new-widgets/callbackMixins/autocompletionMixin.ts b/src/new-widgets/callbackMixins/autocompletionMixin.ts index 64f69a9a..29b66cb3 100644 --- a/src/new-widgets/callbackMixins/autocompletionMixin.ts +++ b/src/new-widgets/callbackMixins/autocompletionMixin.ts @@ -54,6 +54,7 @@ const AutocompletionMixin = { placeholderText: this.placeholder || this.t("autocompletion.placeholder"), searchText: this.searchText || this.t("autocompletion.searchText"), searchPlaceholder: this.searchPlaceholder || this.t("autocompletion.searchPlaceholder"), + contentLocation: this.element, }, events: { searchFilter: (option, filterValue) => fuzzyCompare(option.text, filterValue), -- GitLab From babde4615f360b8700bcba3178f3d25745837f7b Mon Sep 17 00:00:00 2001 From: Anastasia Kryukova <anastasia.kryukova@protonmail.com> Date: Wed, 16 Oct 2024 13:15:36 +0200 Subject: [PATCH 23/66] fix: widgets-form-multiple tests --- cypress/e2e/e2e/widgets-form-multiple.cy.ts | 26 +++++++-------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/cypress/e2e/e2e/widgets-form-multiple.cy.ts b/cypress/e2e/e2e/widgets-form-multiple.cy.ts index 8424d9e3..db21b1cd 100644 --- a/cypress/e2e/e2e/widgets-form-multiple.cy.ts +++ b/cypress/e2e/e2e/widgets-form-multiple.cy.ts @@ -167,8 +167,6 @@ describe('multiple widgets', { testIsolation: false }, function () { }); it('solid-form-multipleselect-autocompletion', () => { - cy.get('solid-form-multipleselect-autocompletion') - .children().should('have.length', 1); cy.get('solid-form-multipleselect-autocompletion') .find('solid-form-dropdown') .should('have.attr', 'data-holder', '') @@ -177,39 +175,33 @@ describe('multiple widgets', { testIsolation: false }, function () { .and('have.attr', 'range', '/examples/data/list/skills.jsonld') .and('have.attr', 'data-src', '/examples/data/list/skills.jsonld') .and('have.attr', 'order-asc', 'name'); - cy.get('solid-form-multipleselect-autocompletion > solid-form-dropdown') - .children().should('have.length', 2); cy.get('solid-form-multipleselect-autocompletion > solid-form-dropdown') .find('select') .should('have.attr', 'data-holder', '') .and('have.attr', 'multiple', 'multiple') .and('have.attr', 'name', 'test1') .and('have.attr', 'style', 'display: none;') - .and('have.attr', 'data-ssid'); - cy.get('solid-form-multipleselect-autocompletion > solid-form-dropdown') - .find('> div') - .children().should('have.length', 2); - cy.get('solid-form-multipleselect-autocompletion > solid-form-dropdown .ss-option').eq(0) + .and('have.attr', 'data-id'); + cy.get('solid-form-multipleselect-autocompletion > div.ss-content > div.ss-list .ss-option').eq(0) .should('contain', 'CSS'); // select values - cy.get('solid-form-multipleselect-autocompletion .ss-main').click(); - cy.get('solid-form-multipleselect-autocompletion .ss-content.ss-open .ss-option').eq(1).click(); + cy.get('solid-form-multipleselect-autocompletion .ss-main').filter(":visible").eq(0).click(); + cy.get('solid-form-multipleselect-autocompletion .ss-content.ss-open-below .ss-option').eq(1).click(); cy.get('solid-form-multipleselect-autocompletion .ss-option').eq(1) - .should('have.class', 'ss-option-selected'); - cy.get('solid-form-multipleselect-autocompletion .ss-values') + .should('have.class', 'ss-selected'); + cy.get('solid-form-multipleselect-autocompletion .ss-values').eq(1) .children().should('have.length', 1) .should('contain', 'DevOps'); - cy.get('solid-form-multipleselect-autocompletion') - .find('.ss-add').click(); }); it('solid-form-autocompletion-placeholder & search attributes', () => { // attributes for placeholders and text displayed in SlimSelect cy.get('#search-attr') - .find('.ss-disabled').contains('Sélectionne une compétence') + .find('.ss-placeholder').filter(":visible").contains('Sélectionne une compétence') .click({force: true}); cy.get('solid-form-multipleselect-autocompletion-placeholder') - .find('.ss-search').children().should('have.attr', 'placeholder', 'Rechercher par clavier') + .find('.ss-search').children().eq(0) + .should('have.attr', 'placeholder', 'Rechercher par clavier') .wait(200) .type('00'); cy.get('#search-attr') -- GitLab From 22f81e25bb4f9f3b33db7ac4658485e57ae1ead6 Mon Sep 17 00:00:00 2001 From: Anastasia Kryukova <anastasia.kryukova@protonmail.com> Date: Wed, 16 Oct 2024 13:19:19 +0200 Subject: [PATCH 24/66] fix translation tests --- cypress/e2e/e2e/translation.cy.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/e2e/translation.cy.ts b/cypress/e2e/e2e/translation.cy.ts index 8ddce2e1..20d71147 100644 --- a/cypress/e2e/e2e/translation.cy.ts +++ b/cypress/e2e/e2e/translation.cy.ts @@ -34,10 +34,10 @@ describe('translation', function () { // french in autompletion multipleselect cy.get('solid-form-search#translation-autocomp') - .find('.ss-placeholder').should('contain', 'Sélectionner une valeur') + .find('.ss-placeholder').filter(":visible").should('contain', 'Sélectionner une valeur') .click(); cy.get('.ss-content') - .find('.ss-search').children().should('have.attr', 'placeholder', 'Rechercher') + .find('.ss-search').filter(":visible").children().should('have.attr', 'placeholder', 'Rechercher') .wait(200).type('00'); cy.get('.ss-content') .find('.ss-list').children().contains('Aucun résultat') @@ -69,10 +69,10 @@ describe('translation', function () { // english in autompletion multipleselect cy.get('solid-form-search#translation-autocomp') - .find('.ss-placeholder').should('contain', 'Select a value') + .find('.ss-placeholder').filter(":visible").should('contain', 'Select a value') .click(); cy.get('.ss-content') - .find('.ss-search').children().should('have.attr', 'placeholder', 'Search') + .find('.ss-search').filter(":visible").children().should('have.attr', 'placeholder', 'Search') .wait(200).type('00'); cy.get('.ss-content') .find('.ss-list').children().contains('No result') -- GitLab From 9fc9b305de2d02fe91102212c9802e1cadc2094e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 15 Nov 2024 20:41:09 +0100 Subject: [PATCH 25/66] update: config biome --- .gitignore | 1 + .gitlab-ci.yml | 1 + biome.jsonc | 33 +++++++++ package-lock.json | 179 ++++++++++++++++++++++++++++++++++++++++++++-- package.json | 3 + 5 files changed, 210 insertions(+), 7 deletions(-) create mode 100644 biome.jsonc diff --git a/.gitignore b/.gitignore index c1f2078c..18b91617 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /node_modules /dist +/cache coverage .nyc_output /cypress/screenshots diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c158bd76..98a37e7e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,6 +32,7 @@ test: before_script: - npm ci script: + - npm run lint - npm run check-types - npm run build - npm test diff --git a/biome.jsonc b/biome.jsonc new file mode 100644 index 00000000..a802df98 --- /dev/null +++ b/biome.jsonc @@ -0,0 +1,33 @@ +{ + "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true + }, + "files": { + "ignoreUnknown": false + }, + "formatter": { + "enabled": false, + "indentStyle": "space" + }, + "organizeImports": { + "enabled": false + }, + "linter": { + "enabled": false, + "rules": { + "recommended": true, + "complexity": { + "useLiteralKeys": "off" + } + } + }, + "javascript": { + "formatter": { + "arrowParentheses": "asNeeded", + "quoteStyle": "single" + } + } +} diff --git a/package-lock.json b/package-lock.json index 7668eaaf..92f0dd4d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "loglevel": "^1.9.1" }, "devDependencies": { + "@biomejs/biome": "1.9.4", "@rckeller/cypress-unfetch": "^1.0.1", "@types/autolinker": "^2.0.0", "@types/leaflet": "^1.9.12", @@ -45,6 +46,170 @@ "vite": "^5.4.8" } }, + "node_modules/@biomejs/biome": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.9.4.tgz", + "integrity": "sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog==", + "dev": true, + "hasInstallScript": true, + "license": "MIT OR Apache-2.0", + "bin": { + "biome": "bin/biome" + }, + "engines": { + "node": ">=14.21.3" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/biome" + }, + "optionalDependencies": { + "@biomejs/cli-darwin-arm64": "1.9.4", + "@biomejs/cli-darwin-x64": "1.9.4", + "@biomejs/cli-linux-arm64": "1.9.4", + "@biomejs/cli-linux-arm64-musl": "1.9.4", + "@biomejs/cli-linux-x64": "1.9.4", + "@biomejs/cli-linux-x64-musl": "1.9.4", + "@biomejs/cli-win32-arm64": "1.9.4", + "@biomejs/cli-win32-x64": "1.9.4" + } + }, + "node_modules/@biomejs/cli-darwin-arm64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.9.4.tgz", + "integrity": "sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-darwin-x64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.9.4.tgz", + "integrity": "sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.9.4.tgz", + "integrity": "sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64-musl": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.9.4.tgz", + "integrity": "sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.9.4.tgz", + "integrity": "sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64-musl": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.9.4.tgz", + "integrity": "sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-arm64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.9.4.tgz", + "integrity": "sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-x64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.9.4.tgz", + "integrity": "sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, "node_modules/@colors/colors": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", @@ -1486,9 +1651,9 @@ } }, "node_modules/cookie": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", - "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", + "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", "dev": true, "license": "MIT", "engines": { @@ -2092,9 +2257,9 @@ } }, "node_modules/express": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/express/-/express-4.21.0.tgz", - "integrity": "sha512-VqcNGcj/Id5ZT1LZ/cfihi3ttTn+NJmkli2eZADigjq29qTlWi/hAQ43t/VLPq8+UX06FCEx3ByOYet6ZFblng==", + "version": "4.21.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", + "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", "dev": true, "license": "MIT", "dependencies": { @@ -2103,7 +2268,7 @@ "body-parser": "1.20.3", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.6.0", + "cookie": "0.7.1", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", diff --git a/package.json b/package.json index 70bb0830..43d31452 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,8 @@ "build": "vite build", "watch": "vite build --watch --sourcemap 'inline'", "serve": "node --watch server.js", + "lint": "biome check", + "lint:fix": "biome check --write", "check-types": "tsc", "test": "node server.js --test", "cypress": "node server.js --test-ui", @@ -65,6 +67,7 @@ "access": "public" }, "devDependencies": { + "@biomejs/biome": "1.9.4", "@rckeller/cypress-unfetch": "^1.0.1", "@types/autolinker": "^2.0.0", "@types/leaflet": "^1.9.12", -- GitLab From dcf1e8f4d9f193d512ee96eb301668728a23cbf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 15 Nov 2024 22:45:26 +0100 Subject: [PATCH 26/66] minor: format --- .jshintrc | 2 +- biome.jsonc | 2 +- cypress.config.ts | 9 +- cypress/e2e/e2e/alias.cy.ts | 106 ++- cypress/e2e/e2e/array-field.cy.ts | 98 ++- cypress/e2e/e2e/auto-range.cy.ts | 181 +++-- cypress/e2e/e2e/binded-attributes.cy.ts | 66 +- cypress/e2e/e2e/default-data-context.cy.ts | 12 +- cypress/e2e/e2e/event-reset-file.cy.ts | 294 ++++---- cypress/e2e/e2e/extra-context.cy.ts | 12 +- cypress/e2e/e2e/federation.cy.ts | 130 ++-- cypress/e2e/e2e/fields-string.cy.ts | 24 +- cypress/e2e/e2e/filteredBy.cy.ts | 34 +- cypress/e2e/e2e/group-by.cy.ts | 64 +- cypress/e2e/e2e/helpers.cy.ts | 216 +++--- cypress/e2e/e2e/navigate-active.cy.ts | 60 +- cypress/e2e/e2e/nested-field.cy.ts | 82 ++- cypress/e2e/e2e/next.cy.ts | 45 +- cypress/e2e/e2e/no-render.cy.ts | 42 +- cypress/e2e/e2e/order-by.cy.ts | 661 ++++++++++------- cypress/e2e/e2e/paginate-by.cy.ts | 115 ++- cypress/e2e/e2e/reactivity-e2e.cy.ts | 342 +++++---- cypress/e2e/e2e/search.cy.ts | 173 +++-- cypress/e2e/e2e/server-pagination.cy.ts | 169 +++-- cypress/e2e/e2e/server-search.cy.ts | 94 +-- cypress/e2e/e2e/sib-register.cy.ts | 2 +- cypress/e2e/e2e/simple-startinblox-e2e.cy.ts | 20 +- cypress/e2e/e2e/solid-ac-checker.cy.ts | 6 +- cypress/e2e/e2e/solid-delete.cy.ts | 34 +- cypress/e2e/e2e/solid-display.cy.ts | 313 +++++--- cypress/e2e/e2e/solid-form-file.cy.ts | 115 +-- cypress/e2e/e2e/solid-form-richtext.cy.ts | 181 +++-- cypress/e2e/e2e/solid-form.cy.ts | 319 ++++---- cypress/e2e/e2e/solid-lang.cy.ts | 30 +- cypress/e2e/e2e/solid-map.cy.ts | 100 ++- cypress/e2e/e2e/solid-table.cy.ts | 184 +++-- cypress/e2e/e2e/solid-widget.cy.ts | 59 +- cypress/e2e/e2e/translation.cy.ts | 77 +- cypress/e2e/e2e/validation.cy.ts | 143 ++-- cypress/e2e/e2e/widgets-custom.cy.ts | 12 +- .../e2e/e2e/widgets-display-multiple.cy.ts | 17 +- cypress/e2e/e2e/widgets-display.cy.ts | 160 +++-- cypress/e2e/e2e/widgets-form-multiple.cy.ts | 297 +++++--- cypress/e2e/e2e/widgets-form.cy.ts | 552 ++++++++------ cypress/e2e/e2e/widgets-sets.cy.ts | 33 +- cypress/e2e/sleep.ts | 2 +- cypress/e2e/unit/ComponentFactory.cy.ts | 4 +- cypress/e2e/unit/Compositor.cy.ts | 2 +- cypress/e2e/unit/helpers.cy.ts | 60 +- cypress/e2e/unit/store.cy.ts | 573 ++++++++------- cypress/fixtures/circles-16.jsonld | 6 +- cypress/fixtures/circles-17-members.jsonld | 8 +- cypress/fixtures/oembed.jsonld | 1 - cypress/fixtures/profiles-alex.jsonld | 4 +- cypress/fixtures/profiles-jbpasquier.jsonld | 4 +- .../profiles-matthieu-edited-2.jsonld | 4 +- .../fixtures/profiles-matthieu-edited.jsonld | 4 +- cypress/fixtures/profiles-matthieu.jsonld | 4 +- cypress/fixtures/users-alex.jsonld | 5 +- cypress/fixtures/users-edited.jsonld | 18 +- cypress/fixtures/users-jbpasquier.jsonld | 5 +- .../users-matthieu-circles-edited.jsonld | 15 +- .../fixtures/users-matthieu-circles.jsonld | 10 +- cypress/fixtures/users-matthieu-edited.jsonld | 5 +- cypress/fixtures/users-matthieu.jsonld | 5 +- cypress/fixtures/users-nantes.jsonld | 9 +- cypress/fixtures/users-paris.jsonld | 14 +- cypress/fixtures/users-source.jsonld | 14 +- cypress/index.d.ts | 9 +- cypress/support/commands.js | 26 +- cypress/support/e2e.js | 6 +- examples/data/calendar/event-1.jsonld | 10 +- examples/data/calendar/event-2.jsonld | 10 +- examples/data/calendar/events.jsonld | 31 +- examples/data/carrot.jsonld | 10 +- examples/data/dfc-enterprise.jsonld | 10 +- examples/data/empty-container.jsonld | 10 +- examples/data/extra-context/user-1.jsonld | 6 +- examples/data/extra-context/user-2.jsonld | 6 +- examples/data/extra-context/user-6.jsonld | 6 +- examples/data/extra-context/users.jsonld | 14 +- .../data/federation/circles-server1.jsonld | 13 +- .../data/federation/circles-server2.jsonld | 13 +- .../data/federation/circles-server3.jsonld | 13 +- .../data/federation/circles-server4.jsonld | 9 +- examples/data/federation/nested-source.jsonld | 8 +- examples/data/federation/source1.jsonld | 8 +- examples/data/federation/source2.jsonld | 8 +- examples/data/galaxy.jsonld | 10 +- examples/data/groups/group1.jsonld | 6 +- examples/data/image.jsonld | 10 +- examples/data/list/chewbacca.jsonld | 6 +- examples/data/list/colibris.jsonld | 102 +-- examples/data/list/community-group.jsonld | 4 +- examples/data/list/darth-vader.json | 6 +- examples/data/list/event-1.jsonld | 20 +- examples/data/list/event-2.jsonld | 18 +- examples/data/list/event-3.jsonld | 18 +- examples/data/list/event-4.jsonld | 18 +- examples/data/list/event-5.jsonld | 130 ++-- examples/data/list/event-empty.jsonld | 20 +- examples/data/list/events.jsonld | 82 +-- examples/data/list/group-3.jsonld | 98 ++- examples/data/list/job-1.jsonld | 8 +- examples/data/list/profile-1.jsonld | 6 +- examples/data/list/profile-2.jsonld | 6 +- examples/data/list/profile-3.jsonld | 6 +- examples/data/list/profile-4.jsonld | 6 +- examples/data/list/profile-5.jsonld | 6 +- examples/data/list/skill-1.jsonld | 9 +- examples/data/list/skill-2.jsonld | 9 +- examples/data/list/skill-3.jsonld | 9 +- examples/data/list/skill-4.jsonld | 9 +- examples/data/list/skill-5.jsonld | 9 +- examples/data/list/skill-6.jsonld | 9 +- examples/data/list/skill-7.jsonld | 9 +- examples/data/list/skill-8.jsonld | 9 +- examples/data/list/skills.jsonld | 44 +- examples/data/list/starwars-origin.jsonld | 24 +- examples/data/list/starwars.jsonld | 4 +- examples/data/list/types.jsonld | 5 +- examples/data/list/universite.jsonld | 11 +- examples/data/list/universite/courses.jsonld | 5 +- examples/data/list/user-1-skills.jsonld | 6 +- examples/data/list/user-1.jsonld | 10 +- examples/data/list/user-2-skills.jsonld | 6 +- examples/data/list/user-2.jsonld | 10 +- examples/data/list/user-3-skills.jsonld | 10 +- examples/data/list/user-3.jsonld | 14 +- examples/data/list/user-4-skills.jsonld | 6 +- examples/data/list/user-4.jsonld | 10 +- examples/data/list/user-5-skills.jsonld | 6 +- examples/data/list/user-5.jsonld | 10 +- examples/data/list/users-group1.jsonld | 34 +- examples/data/list/users-group2.jsonld | 30 +- examples/data/list/users-long.jsonld | 354 +++------ examples/data/list/users-mocked.jsonld | 352 +++------ examples/data/list/users.jsonld | 42 +- examples/data/list/users/balessan.jsonld | 8 +- examples/data/list/users/blaisepascal.jsonld | 8 +- examples/data/map/source.jsonld | 8 +- examples/data/nested-forms/batch-1.jsonld | 22 +- examples/data/nested-forms/batch-2.jsonld | 22 +- .../customer-invoice-1-batches.jsonld | 58 +- .../nested-forms/customer-invoice-1.jsonld | 60 +- examples/data/project.jsonld | 9 +- examples/data/project2.jsonld | 10 +- examples/data/xwiki.jsonld | 10 +- examples/e2e/helpers.css | 8 +- examples/e2e/helpers.js | 2 +- examples/styles.css | 2 +- package.json | 5 +- server.js | 6 +- src/components/solid-ac-checker.ts | 58 +- src/components/solid-calendar.ts | 30 +- src/components/solid-delete.ts | 29 +- src/components/solid-display.ts | 66 +- src/components/solid-form-search.ts | 149 ++-- src/components/solid-form.ts | 156 ++-- src/components/solid-lang.ts | 12 +- src/components/solid-map.ts | 99 ++- src/components/solid-member-add.ts | 36 +- src/components/solid-member-delete.ts | 48 +- src/components/solid-membership.ts | 90 +-- src/components/solid-table.ts | 61 +- src/components/solid-widget.ts | 34 +- src/index.ts | 10 +- src/libs/Component.ts | 6 +- src/libs/ComponentFactory.ts | 111 ++- src/libs/Compositor.ts | 106 +-- src/libs/PostProcessorRegistry.ts | 122 ++-- src/libs/Sib.ts | 103 +-- src/libs/async-query-selector-types.ts | 28 +- src/libs/filter.ts | 174 +++-- src/libs/helpers.ts | 160 +++-- src/libs/interfaces.ts | 46 +- src/libs/lit-helpers.ts | 34 +- src/libs/polyfills.ts | 6 +- src/libs/store/custom-getter.ts | 679 ++++++++++-------- src/libs/store/server-pagination.ts | 39 +- src/libs/store/server-search.ts | 24 +- src/libs/store/store.ts | 348 +++++---- src/locales/en.json | 20 +- src/locales/fr.json | 20 +- src/logger.ts | 314 ++++---- src/mixins/attributeBinderMixin.ts | 59 +- src/mixins/contextMixin.ts | 16 +- src/mixins/counterMixin.ts | 31 +- src/mixins/federationMixin.ts | 37 +- src/mixins/filterMixin.ts | 61 +- src/mixins/grouperMixin.ts | 66 +- src/mixins/highlighterMixin.ts | 39 +- src/mixins/interfaces.ts | 26 +- src/mixins/listMixin.ts | 77 +- src/mixins/nextMixin.ts | 12 +- src/mixins/paginateMixin.ts | 55 +- src/mixins/requiredMixin.ts | 41 +- src/mixins/serverPaginationMixin.ts | 50 +- src/mixins/sorterMixin.ts | 85 ++- src/mixins/storeMixin.ts | 79 +- src/mixins/translationMixin.ts | 32 +- src/mixins/validationMixin.ts | 56 +- src/mixins/widgetMixin.ts | 211 ++++-- .../attributeMixins/actionMixin.ts | 10 +- src/new-widgets/attributeMixins/blankMixin.ts | 8 +- src/new-widgets/attributeMixins/index.ts | 4 +- .../attributeMixins/mailtoMixin.ts | 8 +- .../attributeMixins/multipleMixin.ts | 14 +- .../attributeMixins/placeholderMixin.ts | 13 +- src/new-widgets/attributeMixins/telMixin.ts | 8 +- src/new-widgets/baseWidgetMixin.ts | 37 +- .../callbackMixins/autocompletionMixin.ts | 46 +- src/new-widgets/callbackMixins/index.ts | 8 +- .../callbackMixins/richtextMixin.ts | 85 ++- src/new-widgets/callbackMixins/slimselect.css | 341 ++++++++- src/new-widgets/interfaces.ts | 10 +- src/new-widgets/new-widget-factory.ts | 23 +- .../templateAdditionMixins/addableMixin.ts | 29 +- .../templateAdditionMixins/index.ts | 9 +- .../templateAdditionMixins/labelLastMixin.ts | 13 +- .../templateAdditionMixins/labelMixin.ts | 15 +- .../templates/defaultTemplatesDirectory.ts | 8 +- .../templates/displayTemplatesDirectory.ts | 20 +- .../templates/formTemplatesDirectory.ts | 103 +-- .../templates/groupTemplatesDirectory.ts | 7 +- src/new-widgets/templates/index.ts | 4 +- .../templates/setTemplatesDirectory.ts | 10 +- .../templatesDependencies/altMixin.ts | 14 +- .../templatesDependencies/editableMixin.ts | 28 +- .../filterRangeFormMixin.ts | 32 +- .../formCheckboxMixin.ts | 6 +- .../formCheckboxesMixin.ts | 22 +- .../formDropdownMixin.ts | 39 +- .../templatesDependencies/formFileMixin.ts | 37 +- .../templatesDependencies/formLengthMixin.ts | 10 +- .../templatesDependencies/formMinMaxMixin.ts | 18 +- .../templatesDependencies/formMixin.ts | 37 +- .../templatesDependencies/formNumberMixin.ts | 10 +- .../templatesDependencies/formRadioMixin.ts | 10 +- .../templatesDependencies/formStepMixin.ts | 12 +- .../templatesDependencies/index.ts | 43 +- .../templatesDependencies/linkTextMixin.ts | 8 +- .../multipleFormMixin.ts | 69 +- .../multipleselectFormMixin.ts | 50 +- .../templatesDependencies/patternMixin.ts | 18 +- .../templatesDependencies/rangeMixin.ts | 71 +- .../templatesDependencies/setMixin.ts | 8 +- .../valueRichtextMixin.ts | 8 +- .../autolinkMixin.ts | 17 +- .../valueTransformationMixins/dateMixin.ts | 22 +- .../dateTimeMixin.ts | 22 +- .../valueTransformationMixins/index.ts | 8 +- .../markdownMixin.ts | 20 +- .../multilineMixin.ts | 20 +- .../valueTransformationMixins/oembedMixin.ts | 22 +- src/solid-template-element.ts | 72 +- src/store.d.ts | 4 +- src/style/default-theme.css | 4 +- src/widgets/baseWidget.ts | 127 ++-- src/window.d.ts | 6 +- vite.config.ts | 7 +- 261 files changed, 8099 insertions(+), 6464 deletions(-) diff --git a/.jshintrc b/.jshintrc index 53b202cb..2b6f469f 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,3 +1,3 @@ { "esversion": 6 -} \ No newline at end of file +} diff --git a/biome.jsonc b/biome.jsonc index a802df98..5b48b52f 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -9,7 +9,7 @@ "ignoreUnknown": false }, "formatter": { - "enabled": false, + "enabled": true, "indentStyle": "space" }, "organizeImports": { diff --git a/cypress.config.ts b/cypress.config.ts index 9d7bb283..27d7f890 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -1,15 +1,12 @@ -import { defineConfig } from 'cypress' +import { defineConfig } from 'cypress'; export default defineConfig({ defaultCommandTimeout: 8000, screenshotOnRunFailure: false, video: false, e2e: { - specPattern: [ - "cypress/e2e/unit/*.cy.ts", - "cypress/e2e/e2e/*.cy.ts" - ], + specPattern: ['cypress/e2e/unit/*.cy.ts', 'cypress/e2e/e2e/*.cy.ts'], baseUrl: 'http://0.0.0.0:3000', experimentalRunAllSpecs: true, }, -}) +}); diff --git a/cypress/e2e/e2e/alias.cy.ts b/cypress/e2e/e2e/alias.cy.ts index 31796888..0174c537 100644 --- a/cypress/e2e/e2e/alias.cy.ts +++ b/cypress/e2e/e2e/alias.cy.ts @@ -1,96 +1,136 @@ -describe('alias', function() { +describe('alias', function () { this.beforeEach('visit', () => { - cy.visit('/examples/e2e/alias.html') + cy.visit('/examples/e2e/alias.html'); }); it('display users with alias', () => { - cy.get('#alias-test > div').children().eq(0) + cy.get('#alias-test > div') + .children() + .eq(0) .should('have.attr', 'data-src', '/examples/data/list/user-1.jsonld'); - cy.get('#alias-test > div > solid-display > div').children().eq(0) + cy.get('#alias-test > div > solid-display > div') + .children() + .eq(0) .should('have.attr', 'name', '@id') .should('have.attr', 'value', '/examples/data/list/user-1.jsonld'); - cy.get('#alias-test > div > solid-display > div').children().eq(1) + cy.get('#alias-test > div > solid-display > div') + .children() + .eq(1) .should('have.attr', 'name', '@id as user_id') .should('have.attr', 'value', '/examples/data/list/user-1.jsonld'); - cy.get('#alias-test > div > solid-display > div').children().eq(2) + cy.get('#alias-test > div > solid-display > div') + .children() + .eq(2) .should('have.attr', 'name', 'username') .should('have.attr', 'value', 'admin'); - cy.get('#alias-test > div > solid-display > div').children().eq(3) + cy.get('#alias-test > div > solid-display > div') + .children() + .eq(3) .should('have.attr', 'name', 'username as strangename') .should('have.attr', 'value', 'admin'); - cy.get('#alias-test > div').children().eq(1) + cy.get('#alias-test > div') + .children() + .eq(1) .should('have.attr', 'data-src', '/examples/data/list/user-2.jsonld'); - cy.get('#alias-test > div').children().eq(1) + cy.get('#alias-test > div') + .children() + .eq(1) .find('div > solid-display-value:nth-child(2)') - .should(($element) => { + .should($element => { expect($element).to.have.attr('name', '@id as user_id'); - expect($element).to.have.attr('value', '/examples/data/list/user-2.jsonld'); + expect($element).to.have.attr( + 'value', + '/examples/data/list/user-2.jsonld', + ); }); - cy.get('#alias-test > div').children().eq(1) + cy.get('#alias-test > div') + .children() + .eq(1) .find('div > solid-display-value:nth-child(4)') - .should(($element) => { + .should($element => { expect($element).to.have.attr('name', 'username as strangename'); expect($element).to.have.attr('value', 'paris'); }); - cy.get('#alias-test > div').children().eq(2) + cy.get('#alias-test > div') + .children() + .eq(2) .find('div > solid-display-value:nth-child(2)') - .should(($element) => { + .should($element => { expect($element).to.have.attr('name', '@id as user_id'); - expect($element).to.have.attr('value', '/examples/data/list/user-4.jsonld'); + expect($element).to.have.attr( + 'value', + '/examples/data/list/user-4.jsonld', + ); }); - cy.get('#alias-test > div').children().eq(2) + cy.get('#alias-test > div') + .children() + .eq(2) .find('div > solid-display-value:nth-child(4)') - .should(($element) => { + .should($element => { expect($element).to.have.attr('name', 'username as strangename'); expect($element).to.have.attr('value', 'pierre'); }); }); it('display users with alias for additional fields and sets', () => { - cy.get('#alias-test-2 > div').children().eq(0) + cy.get('#alias-test-2 > div') + .children() + .eq(0) .find('div > solid-display-value:nth-child(6)') - .should(($element) => { + .should($element => { expect($element).to.have.attr('name', 'email as ratatouille'); expect($element).to.have.attr('value', 'test-user@example.com'); }); - cy.get('#alias-test-2 > div').children().eq(1) + cy.get('#alias-test-2 > div') + .children() + .eq(1) .find('div > solid-display-value:nth-child(6)') - .should(($element) => { + .should($element => { expect($element).to.have.attr('name', 'email as ratatouille'); expect($element).to.have.attr('value', 'paris@hilton.hi'); }); - cy.get('#alias-test-2 > div').children().eq(2) + cy.get('#alias-test-2 > div') + .children() + .eq(2) .find('div > solid-set-default > solid-display-value:nth-child(2)') - .should(($element) => { + .should($element => { expect($element).to.have.attr('name', 'username as strangename'); expect($element).to.have.attr('value', 'pierre'); }); }); it('display users with alias and custom widget on aliased field', () => { - cy.get('#alias-test-3 > div').children().eq(0) - .find('div:nth-child(1) > custom-widget:nth-child(2) > div:nth-child(1) > solid-display:nth-child(1) > div:nth-child(1) > solid-display-value:nth-child(4)') - .should(($element) => { + cy.get('#alias-test-3 > div') + .children() + .eq(0) + .find( + 'div:nth-child(1) > custom-widget:nth-child(2) > div:nth-child(1) > solid-display:nth-child(1) > div:nth-child(1) > solid-display-value:nth-child(4)', + ) + .should($element => { expect($element).to.have.attr('name', 'username as strangename'); expect($element).to.have.attr('value', 'admin'); - }); + }); - cy.get('#alias-test-3 > div').children().eq(3) - .find('div:nth-child(1) > custom-widget:nth-child(2) > div:nth-child(1) > solid-display:nth-child(1) > div:nth-child(1) > solid-display-value:nth-child(4)') - .should(($element) => { + cy.get('#alias-test-3 > div') + .children() + .eq(3) + .find( + 'div:nth-child(1) > custom-widget:nth-child(2) > div:nth-child(1) > solid-display:nth-child(1) > div:nth-child(1) > solid-display-value:nth-child(4)', + ) + .should($element => { expect($element).to.have.attr('name', 'username as strangename'); expect($element).to.have.attr('value', 'not-member-paris'); - }); + }); }); -}); \ No newline at end of file +}); diff --git a/cypress/e2e/e2e/array-field.cy.ts b/cypress/e2e/e2e/array-field.cy.ts index 3c901a6b..5f00e773 100644 --- a/cypress/e2e/e2e/array-field.cy.ts +++ b/cypress/e2e/e2e/array-field.cy.ts @@ -1,45 +1,85 @@ -describe('array-field', function() { +describe('array-field', function () { this.beforeEach('visit', () => { - cy.visit('/examples/e2e/array-field.html') + cy.visit('/examples/e2e/array-field.html'); }); it('array-[field]', () => { // data-src in solid-display pointed on user-*.jsonld - cy.get('#display-members > div').children().eq(0) + cy.get('#display-members > div') + .children() + .eq(0) .should('have.attr', 'data-src', '/examples/data/list/user-2.jsonld'); - cy.get('#display-members > div').children().eq(1) - .should('have.attr','data-src', '/examples/data/list/user-1.jsonld'); + cy.get('#display-members > div') + .children() + .eq(1) + .should('have.attr', 'data-src', '/examples/data/list/user-1.jsonld'); // Group's name not displayed - cy.get('#display-members > div').children().eq(0) - .find('solid-display-value').should('not.contain.value', 'LDP_circle_members_1'); - cy.get('#display-members > div').children().eq(1) - .find('solid-display-value').should('not.contain.value', 'LDP_circle_members_1'); + cy.get('#display-members > div') + .children() + .eq(0) + .find('solid-display-value') + .should('not.contain.value', 'LDP_circle_members_1'); + cy.get('#display-members > div') + .children() + .eq(1) + .find('solid-display-value') + .should('not.contain.value', 'LDP_circle_members_1'); // User's name displayed - cy.get('#display-members > div').children().eq(0) - .find('solid-display-value').should('have.attr', 'value', 'Benoit Alessandroni'); - cy.get('#display-members > div').children().eq(1) - .find('solid-display-value').should('have.attr','value', 'Blaise Pascal'); + cy.get('#display-members > div') + .children() + .eq(0) + .find('solid-display-value') + .should('have.attr', 'value', 'Benoit Alessandroni'); + cy.get('#display-members > div') + .children() + .eq(1) + .find('solid-display-value') + .should('have.attr', 'value', 'Blaise Pascal'); }); it('array-field and order-asc', () => { - cy.get('#display-members-asc > div').children().eq(0) - .find('solid-display-value').should('have.attr', 'value', 'Benoit Alessandroni'); - cy.get('#display-members-asc > div').children().eq(1) - .find('solid-display-value').should('have.attr','value', 'Blaise Pascal'); - cy.get('#display-members-asc > div').children().eq(2) - .find('solid-display-value').should('have.attr','value', 'Eric Cantona'); - cy.get('#display-members-asc > div').children().eq(3) - .find('solid-display-value').should('have.attr','value', 'Vitali Klitschko'); + cy.get('#display-members-asc > div') + .children() + .eq(0) + .find('solid-display-value') + .should('have.attr', 'value', 'Benoit Alessandroni'); + cy.get('#display-members-asc > div') + .children() + .eq(1) + .find('solid-display-value') + .should('have.attr', 'value', 'Blaise Pascal'); + cy.get('#display-members-asc > div') + .children() + .eq(2) + .find('solid-display-value') + .should('have.attr', 'value', 'Eric Cantona'); + cy.get('#display-members-asc > div') + .children() + .eq(3) + .find('solid-display-value') + .should('have.attr', 'value', 'Vitali Klitschko'); }); it('array-field and order-desc', () => { - cy.get('#display-members-desc > div').children().eq(0) - .find('solid-display-value').should('have.attr','value', 'Vitali Klitschko'); - cy.get('#display-members-desc > div').children().eq(1) - .find('solid-display-value').should('have.attr','value', 'Eric Cantona'); - cy.get('#display-members-desc > div').children().eq(2) - .find('solid-display-value').should('have.attr','value', 'Blaise Pascal'); - cy.get('#display-members-desc > div').children().eq(3) - .find('solid-display-value').should('have.attr', 'value', 'Benoit Alessandroni'); + cy.get('#display-members-desc > div') + .children() + .eq(0) + .find('solid-display-value') + .should('have.attr', 'value', 'Vitali Klitschko'); + cy.get('#display-members-desc > div') + .children() + .eq(1) + .find('solid-display-value') + .should('have.attr', 'value', 'Eric Cantona'); + cy.get('#display-members-desc > div') + .children() + .eq(2) + .find('solid-display-value') + .should('have.attr', 'value', 'Blaise Pascal'); + cy.get('#display-members-desc > div') + .children() + .eq(3) + .find('solid-display-value') + .should('have.attr', 'value', 'Benoit Alessandroni'); }); }); diff --git a/cypress/e2e/e2e/auto-range.cy.ts b/cypress/e2e/e2e/auto-range.cy.ts index daea28fe..c2844b2c 100644 --- a/cypress/e2e/e2e/auto-range.cy.ts +++ b/cypress/e2e/e2e/auto-range.cy.ts @@ -1,104 +1,165 @@ -describe('auto-range attribute', function() { +describe('auto-range attribute', function () { this.beforeEach('visit', () => { - cy.visit('/examples/e2e/auto-range.html') - }) + cy.visit('/examples/e2e/auto-range.html'); + }); it('solid-form-search + simple auto-range-[field]', () => { - cy.get('#simple-auto-range') - .should('have.attr', 'range-skills'); + cy.get('#simple-auto-range').should('have.attr', 'range-skills'); // one auto-range-[field] => one solid-form-dropdown - cy.get('#simple-auto-range > form') - .children().should('have.length', 1); + cy.get('#simple-auto-range > form').children().should('have.length', 1); cy.get('#simple-auto-range') .find('select') .should('have.attr', 'name', 'skills') - .children().should('have.length', 5); + .children() + .should('have.length', 5); // Skills value visible once in the dropdown - cy.get('#simple-auto-range > form > solid-form-dropdown > select > option').eq(1) + cy.get('#simple-auto-range > form > solid-form-dropdown > select > option') + .eq(1) .should('contain', 'HTML'); - cy.get('#simple-auto-range > form > solid-form-dropdown > select > option').eq(2) + cy.get('#simple-auto-range > form > solid-form-dropdown > select > option') + .eq(2) .should('contain', 'CSS'); - cy.get('#simple-auto-range > form > solid-form-dropdown > select > option').eq(3) + cy.get('#simple-auto-range > form > solid-form-dropdown > select > option') + .eq(3) .should('contain', 'DevOps'); - cy.get('#simple-auto-range > form > solid-form-dropdown > select > option').eq(4) + cy.get('#simple-auto-range > form > solid-form-dropdown > select > option') + .eq(4) .should('contain', 'Node'); // Each skill visible several times - cy.get('#auto-range1 > div') - .children().should('have.length', 3) - cy.get('#auto-range1 > div > solid-display').eq(0) + cy.get('#auto-range1 > div').children().should('have.length', 3); + cy.get('#auto-range1 > div > solid-display') + .eq(0) .should('have.attr', 'data-src', '/examples/data/list/user-2.jsonld') - .find('solid-display[solid-container]').children().children().should('have.length', 1).and('contain', 'HTML') - cy.get('#auto-range1 > div > solid-display').eq(1) + .find('solid-display[solid-container]') + .children() + .children() + .should('have.length', 1) + .and('contain', 'HTML'); + cy.get('#auto-range1 > div > solid-display') + .eq(1) .should('have.attr', 'data-src', '/examples/data/list/user-4.jsonld') - .find('solid-display[solid-container]').children().children().should('have.length', 3).and('contain', 'HTML').and('contain', 'CSS').and('contain', 'DevOps') - cy.get('#auto-range1 > div > solid-display').eq(2) + .find('solid-display[solid-container]') + .children() + .children() + .should('have.length', 3) + .and('contain', 'HTML') + .and('contain', 'CSS') + .and('contain', 'DevOps'); + cy.get('#auto-range1 > div > solid-display') + .eq(2) .should('have.attr', 'data-src', '/examples/data/list/user-5.jsonld') - .find('solid-display[solid-container]').children().children().should('have.length', 3).and('contain', 'HTML').and('contain', 'DevOps').and('contain', 'Node') + .find('solid-display[solid-container]') + .children() + .children() + .should('have.length', 3) + .and('contain', 'HTML') + .and('contain', 'DevOps') + .and('contain', 'Node'); // User visible after selection - cy.get('#simple-auto-range') - .find('select').select('Node') - cy.get('#auto-range1 > div').children().should('have.length', 1) - cy.get('#auto-range1 > div > solid-display') - .should('have.attr', 'data-src', '/examples/data/list/user-5.jsonld') + cy.get('#simple-auto-range').find('select').select('Node'); + cy.get('#auto-range1 > div').children().should('have.length', 1); + cy.get('#auto-range1 > div > solid-display').should( + 'have.attr', + 'data-src', + '/examples/data/list/user-5.jsonld', + ); }); it('solid-form-search with 2 auto-range-[field] + 2 solid-display', () => { - cy.get('#double-auto-range').should('have.attr', 'range-skills') - cy.get('#double-auto-range').should('have.attr', 'range-profile') + cy.get('#double-auto-range').should('have.attr', 'range-skills'); + cy.get('#double-auto-range').should('have.attr', 'range-profile'); // two auto-range-[field] => two solid-form-dropdown - cy.get('#double-auto-range > form') - .children().should('have.length', 2); + cy.get('#double-auto-range > form').children().should('have.length', 2); cy.get('#double-auto-range') .find('select[name="profile"]') - .children().should('have.length', 6); + .children() + .should('have.length', 6); cy.get('#double-auto-range') .find('select[name="skills"]') - .children().should('have.length', 6); + .children() + .should('have.length', 6); // Each profile value visible once in the dropdown - cy.get('#double-auto-range > form > solid-form-dropdown[name="profile"] > select > option').eq(1) + cy.get( + '#double-auto-range > form > solid-form-dropdown[name="profile"] > select > option', + ) + .eq(1) .should('contain', 'profile 1'); - cy.get('#double-auto-range > form > solid-form-dropdown[name="profile"] > select > option').eq(2) + cy.get( + '#double-auto-range > form > solid-form-dropdown[name="profile"] > select > option', + ) + .eq(2) .should('contain', 'profile 2'); - cy.get('#double-auto-range > form > solid-form-dropdown[name="profile"] > select > option').eq(3) + cy.get( + '#double-auto-range > form > solid-form-dropdown[name="profile"] > select > option', + ) + .eq(3) .should('contain', 'profile 3'); - cy.get('#double-auto-range > form > solid-form-dropdown[name="profile"] > select > option').eq(4) + cy.get( + '#double-auto-range > form > solid-form-dropdown[name="profile"] > select > option', + ) + .eq(4) .should('contain', 'profile 4'); - cy.get('#double-auto-range > form > solid-form-dropdown[name="profile"] > select > option').eq(5) + cy.get( + '#double-auto-range > form > solid-form-dropdown[name="profile"] > select > option', + ) + .eq(5) .should('contain', 'profile 5'); // Each skill value visible once in the dropdown - cy.get('#double-auto-range > form > solid-form-dropdown[name="skills"] > select > option').eq(1) + cy.get( + '#double-auto-range > form > solid-form-dropdown[name="skills"] > select > option', + ) + .eq(1) .should('contain', 'CSS'); - cy.get('#double-auto-range > form > solid-form-dropdown[name="skills"] > select > option').eq(2) + cy.get( + '#double-auto-range > form > solid-form-dropdown[name="skills"] > select > option', + ) + .eq(2) .should('contain', 'Javascript'); - cy.get('#double-auto-range > form > solid-form-dropdown[name="skills"] > select > option').eq(3) + cy.get( + '#double-auto-range > form > solid-form-dropdown[name="skills"] > select > option', + ) + .eq(3) .should('contain', 'HTML'); - cy.get('#double-auto-range > form > solid-form-dropdown[name="skills"] > select > option').eq(4) + cy.get( + '#double-auto-range > form > solid-form-dropdown[name="skills"] > select > option', + ) + .eq(4) .should('contain', 'DevOps'); - cy.get('#double-auto-range > form > solid-form-dropdown[name="skills"] > select > option').eq(5) + cy.get( + '#double-auto-range > form > solid-form-dropdown[name="skills"] > select > option', + ) + .eq(5) .should('contain', 'Node'); // User(s) visible after selection + cy.get('#double-auto-range').find('select[name="skills"]').select('HTML'); + cy.get('#auto-range-double > div').children().should('have.length', 1); + cy.get('#auto-range-double > div > solid-display').should( + 'have.attr', + 'data-src', + '/examples/data/list/user-2.jsonld', + ); + cy.get('#auto-range-double2 > div').children().should('have.length', 3); + cy.get('#auto-range-double2 > div > solid-display') + .eq(0) + .should('have.attr', 'data-src', '/examples/data/list/user-2.jsonld'); + cy.get('#auto-range-double2 > div > solid-display') + .eq(1) + .should('have.attr', 'data-src', '/examples/data/list/user-4.jsonld'); + cy.get('#auto-range-double2 > div > solid-display') + .eq(2) + .should('have.attr', 'data-src', '/examples/data/list/user-5.jsonld'); + cy.get('#double-auto-range') - .find('select[name="skills"]').select('HTML') - cy.get('#auto-range-double > div').children().should('have.length', 1) - cy.get('#auto-range-double > div > solid-display') - .should('have.attr', 'data-src', '/examples/data/list/user-2.jsonld') - cy.get('#auto-range-double2 > div').children().should('have.length', 3) - cy.get('#auto-range-double2 > div > solid-display').eq(0) - .should('have.attr', 'data-src', '/examples/data/list/user-2.jsonld') - cy.get('#auto-range-double2 > div > solid-display').eq(1) - .should('have.attr', 'data-src', '/examples/data/list/user-4.jsonld') - cy.get('#auto-range-double2 > div > solid-display').eq(2) - .should('have.attr', 'data-src', '/examples/data/list/user-5.jsonld') - - cy.get('#double-auto-range') - .find('select[name="profile"]').select('profile 4') - cy.get('#auto-range-double > div').should('be.empty') - cy.get('#auto-range-double2 > div').children().should('have.length', 1) - cy.get('#auto-range-double2 > div > solid-display').eq(0) - .should('have.attr', 'data-src', '/examples/data/list/user-4.jsonld') + .find('select[name="profile"]') + .select('profile 4'); + cy.get('#auto-range-double > div').should('be.empty'); + cy.get('#auto-range-double2 > div').children().should('have.length', 1); + cy.get('#auto-range-double2 > div > solid-display') + .eq(0) + .should('have.attr', 'data-src', '/examples/data/list/user-4.jsonld'); }); -}) \ No newline at end of file +}); diff --git a/cypress/e2e/e2e/binded-attributes.cy.ts b/cypress/e2e/e2e/binded-attributes.cy.ts index 1981f79f..e9411660 100644 --- a/cypress/e2e/e2e/binded-attributes.cy.ts +++ b/cypress/e2e/e2e/binded-attributes.cy.ts @@ -1,16 +1,26 @@ // TODO: We should make tests run independently of one another -describe('binded-attributes', { testIsolation: false }, function() { +describe('binded-attributes', { testIsolation: false }, function () { this.beforeAll('visit', () => { - cy.visit('/examples/e2e/binded-attributes.html') + cy.visit('/examples/e2e/binded-attributes.html'); }); it('replace store://resource and store://container and store://user', () => { cy.get('#events') - .should('have.attr', 'value-custom-id', '/examples/data/list/events.jsonld') + .should( + 'have.attr', + 'value-custom-id', + '/examples/data/list/events.jsonld', + ) .and('have.attr', 'value-child-date', 'store://resource.date'); - cy.get('#events solid-display[data-src="/examples/data/list/event-1.jsonld"]') - .should('have.attr', 'value-custom-id', '/examples/data/list/events.jsonld') + cy.get( + '#events solid-display[data-src="/examples/data/list/event-1.jsonld"]', + ) + .should( + 'have.attr', + 'value-custom-id', + '/examples/data/list/events.jsonld', + ) .and('have.attr', 'value-child-date', '2020-07-09'); cy.get('#events').contains('Workshop').click(); @@ -20,15 +30,21 @@ describe('binded-attributes', { testIsolation: false }, function() { .should('have.attr', 'data-src', '/examples/data/list/event-2.jsonld') .and('have.attr', 'value-custom-field', '2020-05-10') .and('have.attr', 'value-wrong-field', 'store://container.@id'); - cy.get('#infos solid-display-value[name="custom-field"]') - .should('have.text', '2020-05-10'); - cy.get('#infos solid-display-value[name="wrong-field"]') - .should('have.text', 'store://container.@id'); + cy.get('#infos solid-display-value[name="custom-field"]').should( + 'have.text', + '2020-05-10', + ); + cy.get('#infos solid-display-value[name="wrong-field"]').should( + 'have.text', + 'store://container.@id', + ); // Works in solid-table cy.get('#table') - .find('tr[data-resource="/examples/data/list/event-1.jsonld"] solid-display-value[name="temp"]') - .should('have.attr', 'value', '/examples/data/list/event-1.jsonld') + .find( + 'tr[data-resource="/examples/data/list/event-1.jsonld"] solid-display-value[name="temp"]', + ) + .should('have.attr', 'value', '/examples/data/list/event-1.jsonld'); // Reset attribute cy.get('solid-route').contains('Events').click(); @@ -36,19 +52,25 @@ describe('binded-attributes', { testIsolation: false }, function() { cy.get('#infos') .should('have.attr', 'data-src', '/examples/data/list/event-1.jsonld') .and('have.attr', 'value-custom-field', '2020-07-09'); - cy.get('#infos solid-display-value[name="custom-field"]') - .should('have.text', '2020-07-09'); - }) + cy.get('#infos solid-display-value[name="custom-field"]').should( + 'have.text', + '2020-07-09', + ); + }); it('replace store://user', () => { - cy.get('#infos') - .should('have.attr', 'value-user', 'Paris'); - cy.get('#infos solid-display-value[name="user"]') - .should('have.text', 'Paris'); - + cy.get('#infos').should('have.attr', 'value-user', 'Paris'); + cy.get('#infos solid-display-value[name="user"]').should( + 'have.text', + 'Paris', + ); + // Back home cy.get('solid-route[name=home]').click(); cy.get('[data-view=home] solid-delete button').should('have.text', 'admin'); - cy.get('[data-view=home] solid-form-search input[type=text]').should('have.value', 'Test'); - }) -}) + cy.get('[data-view=home] solid-form-search input[type=text]').should( + 'have.value', + 'Test', + ); + }); +}); diff --git a/cypress/e2e/e2e/default-data-context.cy.ts b/cypress/e2e/e2e/default-data-context.cy.ts index ac2e2888..43e7e703 100644 --- a/cypress/e2e/e2e/default-data-context.cy.ts +++ b/cypress/e2e/e2e/default-data-context.cy.ts @@ -1,13 +1,11 @@ -describe('default-data-context', function() { +describe('default-data-context', function () { this.beforeEach('visit', () => { - cy.visit('/examples/e2e/default-data-context.html') + cy.visit('/examples/e2e/default-data-context.html'); }); it('default-data-context', () => { - cy.get('solid-display > div').children().eq(0) - .contains('admin'); + cy.get('solid-display > div').children().eq(0).contains('admin'); - cy.get('solid-display > div').children().eq(1) - .contains('Test User'); + cy.get('solid-display > div').children().eq(1).contains('Test User'); }); -}) \ No newline at end of file +}); diff --git a/cypress/e2e/e2e/event-reset-file.cy.ts b/cypress/e2e/e2e/event-reset-file.cy.ts index dc4e01f3..b5c65083 100644 --- a/cypress/e2e/e2e/event-reset-file.cy.ts +++ b/cypress/e2e/e2e/event-reset-file.cy.ts @@ -1,165 +1,179 @@ -describe('event-reset-file', { testIsolation: false }, function() { - this.beforeAll('visit', () => { - cy.visit('/examples/e2e/event-reset-file.html'); - cy.intercept('PUT', 'examples/data/list/event-1.jsonld', {}).as('put') - cy.intercept('PUT', 'examples/data/list/event-empty.jsonld', {}).as('put-empty') +describe('event-reset-file', { testIsolation: false }, function () { + this.beforeAll('visit', () => { + cy.visit('/examples/e2e/event-reset-file.html'); + cy.intercept('PUT', 'examples/data/list/event-1.jsonld', {}).as('put'); + cy.intercept('PUT', 'examples/data/list/event-empty.jsonld', {}).as( + 'put-empty', + ); + }); + + it('should reset form values to initial values after submit event', () => { + cy.get('#form-image').within(() => { + cy.get('input[name="someimage"]') + .should( + 'have.value', + 'https://cdn.startinblox.com/logos/spacelinkers.png', + ) + .type('New Name'); + cy.get('input[type="submit"]').click(); + cy.get('input[name="someimage"]').should( + 'have.value', + 'https://cdn.startinblox.com/logos/spacelinkers.png', + ); }); - - it('should reset form values to initial values after submit event', () => { - - cy.get('#form-image').within(() => { - cy.get('input[name="someimage"]').should('have.value', 'https://cdn.startinblox.com/logos/spacelinkers.png').type('New Name'); - cy.get('input[type="submit"]').click(); - cy.get('input[name="someimage"]').should('have.value', 'https://cdn.startinblox.com/logos/spacelinkers.png'); - }); - - cy.get('#form-1').within(() => { - cy.get('input[name="name"]').should('have.value', 'Coliving').type('New Name'); - cy.get('input[type="submit"]').click(); - - cy.get('input[name="name"]').should('have.value', 'Coliving'); - }); - - cy.get('#form-2').within(() => { - cy.get('input[name="name"]').as('nameInput'); - cy.get('@nameInput').should('have.value', ''); - cy.get('@nameInput').type('New Name'); - cy.get('input[type="submit"]').click(); - - cy.get('@nameInput').should('have.value', ''); - }); - - //[naked] - cy.get('#form-3').within(() => { - cy.get('input[name="name"]').as('nameInput'); - cy.get('@nameInput').type('New Name'); - cy.get('@nameInput').blur(); - - cy.get('@nameInput').should('have.value', 'Coliving'); - }); - - //[naked][autosave] - cy.get('#form-4').within(() => { - cy.get('input[name="name"]').as('nameInput'); - cy.get('@nameInput').clear(); - cy.get('@nameInput').type('New Name'); - cy.get('@nameInput').blur(); - - cy.get('@nameInput').should('have.value', 'New Name'); - }); - - cy.get('#form-5').within(() => { - cy.get('input[name="name"]').as('nameInput'); - cy.get('@nameInput').type('New Name'); - - cy.get('input[type="reset"]').click(); - cy.get('@nameInput').should('have.value', 'Coliving'); - - cy.get('@nameInput').type('New Name'); - cy.get('input[type="submit"]').click(); - cy.get('@nameInput').should('have.value', 'Coliving'); - }); - }); -}) -const Event3Response1 = { - "@id":"http://localhost:8000/events/3/", - "img":"/upload/b9e5d66dda.jpg", - "@context":"https://cdn.startinblox.com/owl/context.jsonld"}; + cy.get('#form-1').within(() => { + cy.get('input[name="name"]') + .should('have.value', 'Coliving') + .type('New Name'); + cy.get('input[type="submit"]').click(); -const Event4Response1 = { - "@id":"http://localhost:8000/events/4/", - "img":"https://letsenhance.io/static/8f5e523ee6b2479e26ecc91b9c25261e/1015f/MainAfter.jpg", - "@context":"https://cdn.startinblox.com/owl/context.jsonld"} + cy.get('input[name="name"]').should('have.value', 'Coliving'); + }); -const Event3Response2 = { - "@id":"http://localhost:8000/events/3/", - "img":"/new/url/image", - "@context":"https://cdn.startinblox.com/owl/context.jsonld"} + cy.get('#form-2').within(() => { + cy.get('input[name="name"]').as('nameInput'); + cy.get('@nameInput').should('have.value', ''); + cy.get('@nameInput').type('New Name'); + cy.get('input[type="submit"]').click(); -const Event4Response2 = { - "@id":"http://localhost:8000/events/4/", - "img":"/new/url/image2", - "@context":"https://cdn.startinblox.com/owl/context.jsonld"} + cy.get('@nameInput').should('have.value', ''); + }); + //[naked] + cy.get('#form-3').within(() => { + cy.get('input[name="name"]').as('nameInput'); + cy.get('@nameInput').type('New Name'); + cy.get('@nameInput').blur(); -describe('event-reset-file-with-route', { testIsolation: false }, function() { - this.beforeAll('visit', () => { - cy.intercept('GET', 'http://localhost:8000/events/3/', Event3Response1); - cy.intercept('GET', 'http://localhost:8000/events/4/', Event4Response1); - cy.visit('/examples/e2e/event-reset-file-with-route.html'); + cy.get('@nameInput').should('have.value', 'Coliving'); }); - - it('should update image source in image input in first route', () => { - cy.get('solid-route[name="route-1"]').click() - cy.get('#form-1').within(() => { - cy.get('input[name="img"]').as('nameInput'); - cy.get('@nameInput').should('have.value',"/upload/b9e5d66dda.jpg" ); - cy.get('@nameInput').type('/new/url/image'); - - cy.intercept('GET', 'http://localhost:8000/events/3/', Event3Response2); - cy.intercept('PUT', 'http://localhost:8000/events/3/', {}); - - cy.get('input[type="submit"]').click(); - cy.get('@nameInput').should('have.value',"/new/url/image" ); - }); + + //[naked][autosave] + cy.get('#form-4').within(() => { + cy.get('input[name="name"]').as('nameInput'); + cy.get('@nameInput').clear(); + cy.get('@nameInput').type('New Name'); + cy.get('@nameInput').blur(); + + cy.get('@nameInput').should('have.value', 'New Name'); }); - it('should update image source in image input in second route', () => { - cy.get('solid-route[name="route-2"]').click() - cy.get('#form-2').within(() => { - cy.get('input[name="img"]').as('nameInput2'); - cy.get('@nameInput2').should('have.value',"https://letsenhance.io/static/8f5e523ee6b2479e26ecc91b9c25261e/1015f/MainAfter.jpg" ); - cy.get('@nameInput2').type('/new/url/image2'); + cy.get('#form-5').within(() => { + cy.get('input[name="name"]').as('nameInput'); + cy.get('@nameInput').type('New Name'); - cy.intercept('GET', 'http://localhost:8000/events/4/', Event4Response2); - cy.intercept('PUT', 'http://localhost:8000/events/4/', {}); + cy.get('input[type="reset"]').click(); + cy.get('@nameInput').should('have.value', 'Coliving'); - cy.get('input[type="submit"]').click(); - cy.get('@nameInput2').should('have.value',"/new/url/image2" ); - }); + cy.get('@nameInput').type('New Name'); + cy.get('input[type="submit"]').click(); + cy.get('@nameInput').should('have.value', 'Coliving'); }); + }); +}); - it('should keep updated values when switch between routes', () => { - cy.intercept('GET', 'http://localhost:8000/events/3/', Event3Response1); - cy.intercept('GET', 'http://localhost:8000/events/4/',Event4Response1); - cy.visit('/examples/e2e/event-reset-file-with-route.html'); +const Event3Response1 = { + '@id': 'http://localhost:8000/events/3/', + img: '/upload/b9e5d66dda.jpg', + '@context': 'https://cdn.startinblox.com/owl/context.jsonld', +}; - cy.get('solid-route[name="route-1"]').click() - cy.get('#form-1').within(() => { - cy.get('input[name="img"]').as('nameInput'); - cy.get('@nameInput').should('have.value',"/upload/b9e5d66dda.jpg" ); - cy.get('@nameInput').type('/new/url/image'); +const Event4Response1 = { + '@id': 'http://localhost:8000/events/4/', + img: 'https://letsenhance.io/static/8f5e523ee6b2479e26ecc91b9c25261e/1015f/MainAfter.jpg', + '@context': 'https://cdn.startinblox.com/owl/context.jsonld', +}; + +const Event3Response2 = { + '@id': 'http://localhost:8000/events/3/', + img: '/new/url/image', + '@context': 'https://cdn.startinblox.com/owl/context.jsonld', +}; - cy.intercept('GET', 'http://localhost:8000/events/3/', Event3Response2); - cy.intercept('PUT', 'http://localhost:8000/events/3/', {}); +const Event4Response2 = { + '@id': 'http://localhost:8000/events/4/', + img: '/new/url/image2', + '@context': 'https://cdn.startinblox.com/owl/context.jsonld', +}; + +describe('event-reset-file-with-route', { testIsolation: false }, function () { + this.beforeAll('visit', () => { + cy.intercept('GET', 'http://localhost:8000/events/3/', Event3Response1); + cy.intercept('GET', 'http://localhost:8000/events/4/', Event4Response1); + cy.visit('/examples/e2e/event-reset-file-with-route.html'); + }); + + it('should update image source in image input in first route', () => { + cy.get('solid-route[name="route-1"]').click(); + cy.get('#form-1').within(() => { + cy.get('input[name="img"]').as('nameInput'); + cy.get('@nameInput').should('have.value', '/upload/b9e5d66dda.jpg'); + cy.get('@nameInput').type('/new/url/image'); + + cy.intercept('GET', 'http://localhost:8000/events/3/', Event3Response2); + cy.intercept('PUT', 'http://localhost:8000/events/3/', {}); + + cy.get('input[type="submit"]').click(); + cy.get('@nameInput').should('have.value', '/new/url/image'); + }); + }); + + it('should update image source in image input in second route', () => { + cy.get('solid-route[name="route-2"]').click(); + cy.get('#form-2').within(() => { + cy.get('input[name="img"]').as('nameInput2'); + cy.get('@nameInput2').should( + 'have.value', + 'https://letsenhance.io/static/8f5e523ee6b2479e26ecc91b9c25261e/1015f/MainAfter.jpg', + ); + cy.get('@nameInput2').type('/new/url/image2'); + + cy.intercept('GET', 'http://localhost:8000/events/4/', Event4Response2); + cy.intercept('PUT', 'http://localhost:8000/events/4/', {}); + + cy.get('input[type="submit"]').click(); + cy.get('@nameInput2').should('have.value', '/new/url/image2'); + }); + }); - cy.get('input[type="submit"]').click(); - cy.get('@nameInput').should('have.value',"/new/url/image" ); - }); + it('should keep updated values when switch between routes', () => { + cy.intercept('GET', 'http://localhost:8000/events/3/', Event3Response1); + cy.intercept('GET', 'http://localhost:8000/events/4/', Event4Response1); + cy.visit('/examples/e2e/event-reset-file-with-route.html'); - cy.get('solid-route[name="route-2"]').click() - cy.get('#form-2').within(() => { - cy.get('input[name="img"]').as('nameInput2'); - cy.get('@nameInput2').should('have.value',"https://letsenhance.io/static/8f5e523ee6b2479e26ecc91b9c25261e/1015f/MainAfter.jpg" ); - cy.get('@nameInput2').type('/new/url/image2'); + cy.get('solid-route[name="route-1"]').click(); + cy.get('#form-1').within(() => { + cy.get('input[name="img"]').as('nameInput'); + cy.get('@nameInput').should('have.value', '/upload/b9e5d66dda.jpg'); + cy.get('@nameInput').type('/new/url/image'); - cy.intercept('GET', 'http://localhost:8000/events/4/', Event4Response2); - cy.intercept('PUT', 'http://localhost:8000/events/4/', {}); + cy.intercept('GET', 'http://localhost:8000/events/3/', Event3Response2); + cy.intercept('PUT', 'http://localhost:8000/events/3/', {}); - cy.get('input[type="submit"]').click(); - cy.get('@nameInput2').should('have.value',"/new/url/image2" ); - }); + cy.get('input[type="submit"]').click(); + cy.get('@nameInput').should('have.value', '/new/url/image'); + }); + cy.get('solid-route[name="route-2"]').click(); + cy.get('#form-2').within(() => { + cy.get('input[name="img"]').as('nameInput2'); + cy.get('@nameInput2').should( + 'have.value', + 'https://letsenhance.io/static/8f5e523ee6b2479e26ecc91b9c25261e/1015f/MainAfter.jpg', + ); + cy.get('@nameInput2').type('/new/url/image2'); - cy.get('solid-route[name="route-1"]').click() - cy.get('@nameInput').should('have.value',"/new/url/image" ); - cy.get('solid-route[name="route-2"]').click() - cy.get('@nameInput2').should('have.value',"/new/url/image2" ); + cy.intercept('GET', 'http://localhost:8000/events/4/', Event4Response2); + cy.intercept('PUT', 'http://localhost:8000/events/4/', {}); + cy.get('input[type="submit"]').click(); + cy.get('@nameInput2').should('have.value', '/new/url/image2'); }); -}); - - - \ No newline at end of file + cy.get('solid-route[name="route-1"]').click(); + cy.get('@nameInput').should('have.value', '/new/url/image'); + cy.get('solid-route[name="route-2"]').click(); + cy.get('@nameInput2').should('have.value', '/new/url/image2'); + }); +}); diff --git a/cypress/e2e/e2e/extra-context.cy.ts b/cypress/e2e/e2e/extra-context.cy.ts index 86234b85..c3da6746 100644 --- a/cypress/e2e/e2e/extra-context.cy.ts +++ b/cypress/e2e/e2e/extra-context.cy.ts @@ -1,13 +1,11 @@ -describe('extra-context', function() { +describe('extra-context', function () { this.beforeEach('visit', () => { - cy.visit('/examples/e2e/extra-context.html') + cy.visit('/examples/e2e/extra-context.html'); }); it('default-data-context', () => { - cy.get('solid-display > div').children().eq(0) - .contains('admin'); + cy.get('solid-display > div').children().eq(0).contains('admin'); - cy.get('solid-display > div').children().eq(1) - .contains('Test User'); + cy.get('solid-display > div').children().eq(1).contains('Test User'); }); -}) \ No newline at end of file +}); diff --git a/cypress/e2e/e2e/federation.cy.ts b/cypress/e2e/e2e/federation.cy.ts index 909451ce..98cba05b 100644 --- a/cypress/e2e/e2e/federation.cy.ts +++ b/cypress/e2e/e2e/federation.cy.ts @@ -3,93 +3,141 @@ let beenCalled = false; describe('federation', { testIsolation: false }, function () { this.beforeAll('visit', () => { cy.visit('/examples/e2e/federation.html'); - }) + }); this.beforeEach(() => { - cy.intercept('http://server.com/skills', (req) => { + cy.intercept('http://server.com/skills', req => { beenCalled = true; req.reply({ body: { - "@context": "https://cdn.startinblox.com/owl/context.jsonld", - "@id": "http://server.com/skills", - "@type": "ldp:Container", - "ldp:contains": [ - {"@id": "http://server.com/skills/1", "name": "HTML"} - ] - } - }) - }) + '@context': 'https://cdn.startinblox.com/owl/context.jsonld', + '@id': 'http://server.com/skills', + '@type': 'ldp:Container', + 'ldp:contains': [ + { '@id': 'http://server.com/skills/1', name: 'HTML' }, + ], + }, + }); + }); }); it('check children', () => { cy.get('#federation-1').as('federation'); - cy.get('@federation').find('> div').children().should('have.length', 4) - cy.get('@federation').find('> div > solid-display[data-src="/examples/data/federation/circles-1.jsonld"]') + cy.get('@federation').find('> div').children().should('have.length', 4); + cy.get('@federation') + .find( + '> div > solid-display[data-src="/examples/data/federation/circles-1.jsonld"]', + ) .should('contain.text', '/examples/data/federation/circles-1.jsonld') .and('contain.text', 'Circle from server 1'); - cy.get('@federation').find('> div > solid-display[data-src="/examples/data/federation/circles-2.jsonld"]') + cy.get('@federation') + .find( + '> div > solid-display[data-src="/examples/data/federation/circles-2.jsonld"]', + ) .should('contain.text', '/examples/data/federation/circles-2.jsonld') .and('contain.text', 'Another circle from server 1'); - cy.get('@federation').find('> div > solid-display[data-src="/examples/data/federation/circles-3.jsonld"]') + cy.get('@federation') + .find( + '> div > solid-display[data-src="/examples/data/federation/circles-3.jsonld"]', + ) .should('contain.text', '/examples/data/federation/circles-3.jsonld') .and('contain.text', 'Circle from server 2'); - cy.get('@federation').find('> div > solid-display[data-src="/examples/data/federation/circles-4.jsonld"]') + cy.get('@federation') + .find( + '> div > solid-display[data-src="/examples/data/federation/circles-4.jsonld"]', + ) .should('contain.text', '/examples/data/federation/circles-4.jsonld') .and('contain.text', 'Another circle from server 2'); }); it('supports nested sources', () => { cy.get('#federation-2').as('federation'); - cy.get('@federation').find('> div').children().should('have.length', 6) - cy.get('@federation').find('> div > solid-display[data-src="/examples/data/federation/circles-1.jsonld"]') + cy.get('@federation').find('> div').children().should('have.length', 6); + cy.get('@federation') + .find( + '> div > solid-display[data-src="/examples/data/federation/circles-1.jsonld"]', + ) .should('contain.text', '/examples/data/federation/circles-1.jsonld') .and('contain.text', 'Circle from server 1'); - cy.get('@federation').find('> div > solid-display[data-src="/examples/data/federation/circles-2.jsonld"]') + cy.get('@federation') + .find( + '> div > solid-display[data-src="/examples/data/federation/circles-2.jsonld"]', + ) .should('contain.text', '/examples/data/federation/circles-2.jsonld') .and('contain.text', 'Another circle from server 1'); - cy.get('@federation').find('> div > solid-display[data-src="/examples/data/federation/circles-3.jsonld"]') + cy.get('@federation') + .find( + '> div > solid-display[data-src="/examples/data/federation/circles-3.jsonld"]', + ) .should('contain.text', '/examples/data/federation/circles-3.jsonld') .and('contain.text', 'Circle from server 2'); - cy.get('@federation').find('> div > solid-display[data-src="/examples/data/federation/circles-4.jsonld"]') + cy.get('@federation') + .find( + '> div > solid-display[data-src="/examples/data/federation/circles-4.jsonld"]', + ) .should('contain.text', '/examples/data/federation/circles-4.jsonld') .and('contain.text', 'Another circle from server 2'); - cy.get('@federation').find('> div > solid-display[data-src="/examples/data/federation/circles-5.jsonld"]') + cy.get('@federation') + .find( + '> div > solid-display[data-src="/examples/data/federation/circles-5.jsonld"]', + ) .should('contain.text', '/examples/data/federation/circles-5.jsonld') .and('contain.text', 'Circle from server 3'); - cy.get('@federation').find('> div > solid-display[data-src="/examples/data/federation/circles-6.jsonld"]') + cy.get('@federation') + .find( + '> div > solid-display[data-src="/examples/data/federation/circles-6.jsonld"]', + ) .should('contain.text', '/examples/data/federation/circles-6.jsonld') .and('contain.text', 'Circle from server 4'); }); - it("can fail one source", () => { + it('can fail one source', () => { cy.intercept('GET', '/examples/data/federation/circles-server3.jsonld', { - statusCode: 403 - }) + statusCode: 403, + }); cy.reload(); cy.get('#federation-2').as('federation'); cy.get('@federation').find('> div').children().should('have.length', 5); - cy.get('@federation').find('> div > solid-display[data-src="/examples/data/federation/circles-1.jsonld"]') - .and('contain.text', '/examples/data/federation/circles-1.jsonld') - .and('contain.text', 'Circle from server 1'); - cy.get('@federation').find('> div > solid-display[data-src="/examples/data/federation/circles-2.jsonld"]') + cy.get('@federation') + .find( + '> div > solid-display[data-src="/examples/data/federation/circles-1.jsonld"]', + ) + .and('contain.text', '/examples/data/federation/circles-1.jsonld') + .and('contain.text', 'Circle from server 1'); + cy.get('@federation') + .find( + '> div > solid-display[data-src="/examples/data/federation/circles-2.jsonld"]', + ) .should('contain.text', '/examples/data/federation/circles-2.jsonld') .and('contain.text', 'Another circle from server 1'); - cy.get('@federation').find('> div > solid-display[data-src="/examples/data/federation/circles-3.jsonld"]') + cy.get('@federation') + .find( + '> div > solid-display[data-src="/examples/data/federation/circles-3.jsonld"]', + ) .should('contain.text', '/examples/data/federation/circles-3.jsonld') .and('contain.text', 'Circle from server 2'); - cy.get('@federation').find('> div > solid-display[data-src="/examples/data/federation/circles-4.jsonld"]') + cy.get('@federation') + .find( + '> div > solid-display[data-src="/examples/data/federation/circles-4.jsonld"]', + ) .should('contain.text', '/examples/data/federation/circles-4.jsonld') .and('contain.text', 'Another circle from server 2'); - cy.get('@federation').find('> div > solid-display[data-src="/examples/data/federation/circles-6.jsonld"]') + cy.get('@federation') + .find( + '> div > solid-display[data-src="/examples/data/federation/circles-6.jsonld"]', + ) .should('contain.text', '/examples/data/federation/circles-6.jsonld') .and('contain.text', 'Circle from server 4'); - }) + }); - it("does not fetch local federations", () => { + it('does not fetch local federations', () => { expect(beenCalled).to.be.false; - cy.get('#loadSkills').click() - cy.get('#federation-3 solid-display > div').children().should('have.length', 1).then(() => { - expect(beenCalled).to.be.true; - }) - }) -}) + cy.get('#loadSkills').click(); + cy.get('#federation-3 solid-display > div') + .children() + .should('have.length', 1) + .then(() => { + expect(beenCalled).to.be.true; + }); + }); +}); diff --git a/cypress/e2e/e2e/fields-string.cy.ts b/cypress/e2e/e2e/fields-string.cy.ts index a8933419..0b82b312 100644 --- a/cypress/e2e/e2e/fields-string.cy.ts +++ b/cypress/e2e/e2e/fields-string.cy.ts @@ -1,25 +1,19 @@ -describe('fields-string', function() { +describe('fields-string', function () { this.beforeEach('visit', () => { - cy.visit('/examples/e2e/fields-string.html') + cy.visit('/examples/e2e/fields-string.html'); }); it('display strings', () => { cy.get('#list-1 > div').as('list1'); cy.get('#list-2 > div').as('list2'); - cy.get('@list1').children() - .should('have.length', 4); - cy.get('@list2').children() - .should('have.length', 4); + cy.get('@list1').children().should('have.length', 4); + cy.get('@list2').children().should('have.length', 4); - cy.get('@list1').find('>span').eq(0) - .should('have.text', 'Name: ') - cy.get('@list2').find('>span').eq(0) - .should('have.text', 'Name: ') + cy.get('@list1').find('>span').eq(0).should('have.text', 'Name: '); + cy.get('@list2').find('>span').eq(0).should('have.text', 'Name: '); - cy.get('@list1').find('>span').eq(1) - .should('have.text', ', description: ') - cy.get('@list2').find('>span').eq(1) - .should('have.text', ', description: ') + cy.get('@list1').find('>span').eq(1).should('have.text', ', description: '); + cy.get('@list2').find('>span').eq(1).should('have.text', ', description: '); }); -}) +}); diff --git a/cypress/e2e/e2e/filteredBy.cy.ts b/cypress/e2e/e2e/filteredBy.cy.ts index 7fe8f519..55c8d5e8 100644 --- a/cypress/e2e/e2e/filteredBy.cy.ts +++ b/cypress/e2e/e2e/filteredBy.cy.ts @@ -1,13 +1,23 @@ -describe('simple Startin’blox e2e test', function() { +describe('simple Startin’blox e2e test', function () { it('check children count', () => { - cy.visit('/examples/filtered.html') - cy.get('#filter1 input').type('ma#er') // match "mayer" - cy.get('#filter2 input').type('linds') // match "lindsay", "collins" & "rollins" - cy.get('main > div:nth-child(1) > solid-display > div > solid-display').its('length').should('eq', 1); - cy.get('main > div:nth-child(2) > solid-display > div > solid-display').its('length').should('eq', 1); - cy.get('#filter1 input').clear().type('john') // match "johnston.ashley" & "frye.johns" - cy.get('main > div:nth-child(1) > solid-display > div > solid-display').its('length').should('eq', 2); - cy.get('main > div:nth-child(2) > form input[value="filter2"]').click({force: true}); - cy.get('main > div:nth-child(2) > solid-display > div > solid-display').its('length').should('eq', 3); - }) -}) + cy.visit('/examples/filtered.html'); + cy.get('#filter1 input').type('ma#er'); // match "mayer" + cy.get('#filter2 input').type('linds'); // match "lindsay", "collins" & "rollins" + cy.get('main > div:nth-child(1) > solid-display > div > solid-display') + .its('length') + .should('eq', 1); + cy.get('main > div:nth-child(2) > solid-display > div > solid-display') + .its('length') + .should('eq', 1); + cy.get('#filter1 input').clear().type('john'); // match "johnston.ashley" & "frye.johns" + cy.get('main > div:nth-child(1) > solid-display > div > solid-display') + .its('length') + .should('eq', 2); + cy.get('main > div:nth-child(2) > form input[value="filter2"]').click({ + force: true, + }); + cy.get('main > div:nth-child(2) > solid-display > div > solid-display') + .its('length') + .should('eq', 3); + }); +}); diff --git a/cypress/e2e/e2e/group-by.cy.ts b/cypress/e2e/e2e/group-by.cy.ts index f362cbed..fa41cb6f 100644 --- a/cypress/e2e/e2e/group-by.cy.ts +++ b/cypress/e2e/e2e/group-by.cy.ts @@ -1,30 +1,33 @@ -describe('group-by', function() { +describe('group-by', function () { this.beforeEach('visit', () => { - cy.visit('/examples/e2e/group-by.html') - }) + cy.visit('/examples/e2e/group-by.html'); + }); /** - * Groups resource at loading time - */ + * Groups resource at loading time + */ it('groups resources', () => { cy.get('#list-1 > div > solid-group-default') // get groups - .should('have.length', 3) // check number - .and('have.class', 'custom-group-class'); // and class + .should('have.length', 3) // check number + .and('have.class', 'custom-group-class'); // and class cy.get('#list-1 > div > solid-group-default:first-child > span') // check title span .should('have.length', 1) .contains('2020-07-09'); cy.get('#list-1 > div > solid-group-default:first-child > div') // check content div - .should('have.length', 1) - .and('have.attr', 'data-content'); - cy.get('#list-1 > div > solid-group-default:first-child > div > solid-display') // check solid-display - .should('have.length', 1); - }) + .should('have.length', 1) + .and('have.attr', 'data-content'); + cy.get( + '#list-1 > div > solid-group-default:first-child > div > solid-display', + ) // check solid-display + .should('have.length', 1); + }); /** - * Group and pagination work together - */ + * Group and pagination work together + */ it('groups resources and paginate', () => { - cy.get('#list-2 > div').within(() => { // in list-2 + cy.get('#list-2 > div').within(() => { + // in list-2 cy.get('> solid-group-default').eq(1).as('groupRow'); // get second group cy.get('@groupRow').find('nav').as('navPages'); // check if nav is here @@ -34,21 +37,30 @@ describe('group-by', function() { cy.get('@navPages').find('> span [data-id=count]').contains('2'); // Test content - cy.get('@groupRow').find('solid-display-value[name]').contains('Workshop'); + cy.get('@groupRow') + .find('solid-display-value[name]') + .contains('Workshop'); cy.get('@navPages').find('[data-id=next]').click(); }); - cy.get('#list-2 > div > solid-group-default').eq(1).find('solid-display-value[name]').contains('Assemblée générale'); + cy.get('#list-2 > div > solid-group-default') + .eq(1) + .find('solid-display-value[name]') + .contains('Assemblée générale'); }); - + /** - * Group widgets - */ + * Group widgets + */ it('groups resources in custom widgets', () => { cy.get('#list-3 > div > custom-group').should('have.length', 3); - cy.get('#list-3 > div > custom-group').eq(0).find('h2') - .should('contain', "2020") - cy.get('#list-3 > div > custom-group').eq(0).find('section') - .should('have.attr', "data-content"); - }) -}) + cy.get('#list-3 > div > custom-group') + .eq(0) + .find('h2') + .should('contain', '2020'); + cy.get('#list-3 > div > custom-group') + .eq(0) + .find('section') + .should('have.attr', 'data-content'); + }); +}); diff --git a/cypress/e2e/e2e/helpers.cy.ts b/cypress/e2e/e2e/helpers.cy.ts index dba41bdb..e69b6400 100644 --- a/cypress/e2e/e2e/helpers.cy.ts +++ b/cypress/e2e/e2e/helpers.cy.ts @@ -1,6 +1,6 @@ -import sleep from '../sleep' +import sleep from '../sleep'; -describe('helpers', function() { +describe('helpers', function () { let helpers: typeof import('../../../src/libs/helpers'); let win: Window; let doc: Document; @@ -11,62 +11,68 @@ describe('helpers', function() { doc = win.document; ///@ts-ignore helpers = win.helpers; - doc - .querySelectorAll('script') - .forEach(script => script.remove()); + doc.querySelectorAll('script').forEach(script => script.remove()); }); }); describe('generalComparator Function Tests', () => { it('should compare two numbers correctly', () => { - expect(helpers.generalComparator(5, 10)).to.equal(-5); - expect(helpers.generalComparator(10, 5)).to.equal(5); - expect(helpers.generalComparator(5, 5)).to.equal(0); + expect(helpers.generalComparator(5, 10)).to.equal(-5); + expect(helpers.generalComparator(10, 5)).to.equal(5); + expect(helpers.generalComparator(5, 5)).to.equal(0); }); it('should compare two strings correctly', () => { - expect(helpers.generalComparator('apple', 'banana')).to.be.lessThan(0); - expect(helpers.generalComparator('panana', 'banana')).to.be.greaterThan(0); - expect(helpers.generalComparator('apple', 'apple')).to.equal(0); + expect(helpers.generalComparator('apple', 'banana')).to.be.lessThan(0); + expect(helpers.generalComparator('panana', 'banana')).to.be.greaterThan( + 0, + ); + expect(helpers.generalComparator('apple', 'apple')).to.equal(0); }); it('should compare dates correctly', () => { - const date1 = new Date('2024-01-01'); - const date2 = new Date('2024-12-31'); - expect(helpers.generalComparator(date1, date2)).to.be.lessThan(0); - expect(helpers.generalComparator(date2, date1)).to.be.greaterThan(0); - expect(helpers.generalComparator(date1, date1)).to.equal(0); + const date1 = new Date('2024-01-01'); + const date2 = new Date('2024-12-31'); + expect(helpers.generalComparator(date1, date2)).to.be.lessThan(0); + expect(helpers.generalComparator(date2, date1)).to.be.greaterThan(0); + expect(helpers.generalComparator(date1, date1)).to.equal(0); }); it('should compare booleans correctly', () => { - expect(helpers.generalComparator(true, false)).to.equal(1); - expect(helpers.generalComparator(false, true)).to.equal(-1); - expect(helpers.generalComparator(true, true)).to.equal(0); + expect(helpers.generalComparator(true, false)).to.equal(1); + expect(helpers.generalComparator(false, true)).to.equal(-1); + expect(helpers.generalComparator(true, true)).to.equal(0); }); it('should compare arrays by length', () => { - expect(helpers.generalComparator([1, 2], [1, 2, 3])).to.be.lessThan(0); - expect(helpers.generalComparator([1, 2, 3], [1, 2])).to.be.greaterThan(0); - expect(helpers.generalComparator([1, 2, 3], [4, 5, 6])).to.equal(0); + expect(helpers.generalComparator([1, 2], [1, 2, 3])).to.be.lessThan(0); + expect(helpers.generalComparator([1, 2, 3], [1, 2])).to.be.greaterThan(0); + expect(helpers.generalComparator([1, 2, 3], [4, 5, 6])).to.equal(0); }); it('should compare objects by number of keys', () => { - expect(helpers.generalComparator({ a: 1 }, { a: 1, b: 2 })).to.be.lessThan(0); - expect(helpers.generalComparator({ a: 1, b: 2 }, { a: 1 })).to.be.greaterThan(0); - expect(helpers.generalComparator({ a: 1, b: 2 }, { x: 10, y: 20 })).to.equal(0); + expect( + helpers.generalComparator({ a: 1 }, { a: 1, b: 2 }), + ).to.be.lessThan(0); + expect( + helpers.generalComparator({ a: 1, b: 2 }, { a: 1 }), + ).to.be.greaterThan(0); + expect( + helpers.generalComparator({ a: 1, b: 2 }, { x: 10, y: 20 }), + ).to.equal(0); }); it('should handle null or undefined values', () => { - expect(helpers.generalComparator(null, undefined)).to.equal(0); - expect(helpers.generalComparator(null, 1)).to.equal(-1); - expect(helpers.generalComparator(1, null)).to.equal(1); + expect(helpers.generalComparator(null, undefined)).to.equal(0); + expect(helpers.generalComparator(null, 1)).to.equal(-1); + expect(helpers.generalComparator(1, null)).to.equal(1); }); it('should handle different orders correctly', () => { - expect(helpers.generalComparator(5, 10, 'asc')).to.be.lessThan(0); - expect(helpers.generalComparator(5, 10, 'desc')).to.be.greaterThan(0); + expect(helpers.generalComparator(5, 10, 'asc')).to.be.lessThan(0); + expect(helpers.generalComparator(5, 10, 'desc')).to.be.greaterThan(0); }); -}); + }); describe('importCSS', () => { it('add one stylesheet', () => { @@ -96,9 +102,7 @@ describe('helpers', function() { const url = 'helpers.css'; helpers.importCSS(url); helpers.importCSS(url); - cy.get('link') - .its('length') - .should('eq', 1); + cy.get('link').its('length').should('eq', 1); }); }); @@ -107,12 +111,16 @@ describe('helpers', function() { helpers.importInlineCSS('test1', 'html {background-color: green}'); cy.get('html').should('have.css', 'background-color', 'rgb(0, 128, 0)'); }); - + it('avoid import stylesheet twice', () => { helpers.importInlineCSS('test2', 'html {background-color: green}'); helpers.importInlineCSS('test2', 'html {background-color: red}'); cy.get('html').should('have.css', 'background-color', 'rgb(0, 128, 0)'); - cy.get('html').should('not.have.css', 'background-color', 'rgb(255, 0, 0)'); + cy.get('html').should( + 'not.have.css', + 'background-color', + 'rgb(255, 0, 0)', + ); }); }); @@ -142,24 +150,22 @@ describe('helpers', function() { expect(srcs).deep.eq(urls.map(url => new URL(url, doc.baseURI).href)); }); }); - + it('add script only once', () => { const url = 'script'; helpers.importJS(url); helpers.importJS(url); - cy.get('script') - .its('length') - .should('eq', 1); + cy.get('script').its('length').should('eq', 1); }); }); - describe('defineComponent', function() { + describe('defineComponent', function () { it('define my-component', () => { expect(win.customElements.get('my-component')).to.be.undefined; helpers.defineComponent('my-component', class extends HTMLElement {}); expect(win.customElements.get('my-component')).to.not.be.undefined; }); - + it('show a warning', () => { const spy = cy.spy((win as Window & typeof globalThis).console, 'warn'); helpers.defineComponent('my-component', class extends HTMLElement {}); @@ -168,83 +174,95 @@ describe('helpers', function() { }); }); - describe('asyncQuerySelector', function () { it('select an element already in document', async () => { - const list = doc.querySelector('#async-qs ul')! - const list2 = await helpers.asyncQuerySelector('#async-qs ul') - expect(list2).to.equal(list) - }) + const list = doc.querySelector('#async-qs ul')!; + const list2 = await helpers.asyncQuerySelector('#async-qs ul'); + expect(list2).to.equal(list); + }); it('select an element already in another element', async () => { - const list = doc.querySelector('#async-qs ul')! - const first1 = list.querySelector<HTMLLIElement>(':scope > :first-child') + const list = doc.querySelector('#async-qs ul')!; + const first1 = list.querySelector<HTMLLIElement>(':scope > :first-child'); const first2 = await helpers.asyncQuerySelector<HTMLLIElement>( ':scope > :first-child', list, - ) - expect(first2).to.equal(first1!) - }) + ); + expect(first2).to.equal(first1!); + }); it('select an element not yet in the DOM', async () => { - const list = doc.querySelector('#async-qs ul')! - const li = doc.createElement('li') - li.classList.add('added') - setTimeout(() => list.append(li)) - const added1 = list.querySelector(':scope > .added') - expect(added1).to.be.null - const added2 = await helpers.asyncQuerySelector(':scope > .added', list) - const added3 = list.querySelector(':scope > .added') - expect(added2).to.equal(added3!) - }) + const list = doc.querySelector('#async-qs ul')!; + const li = doc.createElement('li'); + li.classList.add('added'); + setTimeout(() => list.append(li)); + const added1 = list.querySelector(':scope > .added'); + expect(added1).to.be.null; + const added2 = await helpers.asyncQuerySelector(':scope > .added', list); + const added3 = list.querySelector(':scope > .added'); + expect(added2).to.equal(added3!); + }); it('select an element not yet matching selector', async () => { - const list = doc.querySelector('#async-qs ul')! - const li = doc.createElement('li') - list.append(li) - setTimeout(() => li.classList.add('classed')) - const classed1 = list.querySelector(':scope > .classed') - expect(classed1).to.be.null - const classed2 = await helpers.asyncQuerySelector(':scope > .classed', list) - const classed3 = list.querySelector(':scope > .classed') - expect(classed2).to.equal(classed3!) - }) + const list = doc.querySelector('#async-qs ul')!; + const li = doc.createElement('li'); + list.append(li); + setTimeout(() => li.classList.add('classed')); + const classed1 = list.querySelector(':scope > .classed'); + expect(classed1).to.be.null; + const classed2 = await helpers.asyncQuerySelector( + ':scope > .classed', + list, + ); + const classed3 = list.querySelector(':scope > .classed'); + expect(classed2).to.equal(classed3!); + }); it('select an element generated by a solid-display', () => { cy.get('#async-qs').then(async div => { - const sd = div.append(/* html */ `<solid-display data-src="/examples/data/list/event-1.jsonld" + const sd = + div.append(/* html */ `<solid-display data-src="/examples/data/list/event-1.jsonld" fields="event, name, date" widget-date="solid-display-value-date" - >`)[0] - const sdv = await helpers.asyncQuerySelector('solid-display-value-date', sd) - expect(sdv).has.nested.property('component.name', 'date') - }) - }) - }) + >`)[0]; + const sdv = await helpers.asyncQuerySelector( + 'solid-display-value-date', + sd, + ); + expect(sdv).has.nested.property('component.name', 'date'); + }); + }); + }); describe('asyncQuerySelectorAll', () => { - const items: Element[] = [] + const items: Element[] = []; it('select currents and futures elements in DOM', async () => { - const list = doc.querySelector('#async-qs ol')! - ;(async () => { - for await (const li of helpers.asyncQuerySelectorAll('li', list)) items.push(li) - })() - await sleep() - expect(items).to.have.length(2) + const list = doc.querySelector('#async-qs ol')!; + (async () => { + for await (const li of helpers.asyncQuerySelectorAll('li', list)) + items.push(li); + })(); + await sleep(); + expect(items).to.have.length(2); for (let index = 0; index < 3; index++) - list.append(doc.createElement('li')) - await sleep() - expect(items).to.have.length(5) - }) + list.append(doc.createElement('li')); + await sleep(); + expect(items).to.have.length(5); + }); it('select elements generated by a solid-display', () => { cy.get('#async-qs').then(async div => { - const sd = div.append(/* html */ `<solid-display data-src="/examples/data/list/users.jsonld">`)[0] - let limit = 20 - for await (const sdv of helpers.asyncQuerySelectorAll<HTMLElement>('solid-display-value', sd)) { - if (limit-- <= 0) break - expect(sdv).has.nested.property('component.name') - sdv.style.background = '#9f9' + const sd = div.append( + /* html */ `<solid-display data-src="/examples/data/list/users.jsonld">`, + )[0]; + let limit = 20; + for await (const sdv of helpers.asyncQuerySelectorAll<HTMLElement>( + 'solid-display-value', + sd, + )) { + if (limit-- <= 0) break; + expect(sdv).has.nested.property('component.name'); + sdv.style.background = '#9f9'; } - }) - }) - }) + }); + }); + }); }); diff --git a/cypress/e2e/e2e/navigate-active.cy.ts b/cypress/e2e/e2e/navigate-active.cy.ts index 477b3d0a..a57be6a0 100644 --- a/cypress/e2e/e2e/navigate-active.cy.ts +++ b/cypress/e2e/e2e/navigate-active.cy.ts @@ -1,29 +1,53 @@ // TODO: We should make tests run independently of one another describe('uses active on navigate', { testIsolation: false }, function () { this.beforeAll('visit', () => { - cy.visit('/examples/e2e/active-navigate.html').as("loadPage") + cy.visit('/examples/e2e/active-navigate.html').as('loadPage'); }); it('set active by default | unset active on leaveRoute | set active on enterRoute', () => { - cy.get('solid-display[data-src="/examples/data/list/user-2.jsonld"]').should('exist').and('have.attr', 'active'); - cy.get('solid-display[data-src="/examples/data/list/user-1.jsonld"]').should('exist').and('not.have.attr', 'active'); - cy.get('solid-display[data-src="/examples/data/list/user-3.jsonld"]').should('exist').and('not.have.attr', 'active'); - cy.get('solid-display[data-src="/examples/data/list/user-4.jsonld"]').should('exist').and('not.have.attr', 'active'); + cy.get('solid-display[data-src="/examples/data/list/user-2.jsonld"]') + .should('exist') + .and('have.attr', 'active'); + cy.get('solid-display[data-src="/examples/data/list/user-1.jsonld"]') + .should('exist') + .and('not.have.attr', 'active'); + cy.get('solid-display[data-src="/examples/data/list/user-3.jsonld"]') + .should('exist') + .and('not.have.attr', 'active'); + cy.get('solid-display[data-src="/examples/data/list/user-4.jsonld"]') + .should('exist') + .and('not.have.attr', 'active'); }); - it("unset active on leaveRoute", () => { + it('unset active on leaveRoute', () => { cy.get('#leave-route').click(); - cy.get('solid-display[data-src="/examples/data/list/user-1.jsonld"]').should('not.have.attr', 'active'); - cy.get('solid-display[data-src="/examples/data/list/user-2.jsonld"]').should('not.have.attr', 'active'); - cy.get('solid-display[data-src="/examples/data/list/user-3.jsonld"]').should('not.have.attr', 'active'); - cy.get('solid-display[data-src="/examples/data/list/user-4.jsonld"]').should('not.have.attr', 'active'); - }) + cy.get( + 'solid-display[data-src="/examples/data/list/user-1.jsonld"]', + ).should('not.have.attr', 'active'); + cy.get( + 'solid-display[data-src="/examples/data/list/user-2.jsonld"]', + ).should('not.have.attr', 'active'); + cy.get( + 'solid-display[data-src="/examples/data/list/user-3.jsonld"]', + ).should('not.have.attr', 'active'); + cy.get( + 'solid-display[data-src="/examples/data/list/user-4.jsonld"]', + ).should('not.have.attr', 'active'); + }); - it("set active on enterRoute", () => { + it('set active on enterRoute', () => { cy.get('#enter-route').click(); - cy.get('solid-display[data-src="/examples/data/list/user-1.jsonld"]').should('have.attr', 'active'); - cy.get('solid-display[data-src="/examples/data/list/user-2.jsonld"]').should('not.have.attr', 'active'); - cy.get('solid-display[data-src="/examples/data/list/user-3.jsonld"]').should('not.have.attr', 'active'); - cy.get('solid-display[data-src="/examples/data/list/user-4.jsonld"]').should('not.have.attr', 'active'); - }) -}) + cy.get( + 'solid-display[data-src="/examples/data/list/user-1.jsonld"]', + ).should('have.attr', 'active'); + cy.get( + 'solid-display[data-src="/examples/data/list/user-2.jsonld"]', + ).should('not.have.attr', 'active'); + cy.get( + 'solid-display[data-src="/examples/data/list/user-3.jsonld"]', + ).should('not.have.attr', 'active'); + cy.get( + 'solid-display[data-src="/examples/data/list/user-4.jsonld"]', + ).should('not.have.attr', 'active'); + }); +}); diff --git a/cypress/e2e/e2e/nested-field.cy.ts b/cypress/e2e/e2e/nested-field.cy.ts index 1261f17a..2dd49149 100644 --- a/cypress/e2e/e2e/nested-field.cy.ts +++ b/cypress/e2e/e2e/nested-field.cy.ts @@ -1,43 +1,73 @@ -describe('nested-field', function() { +describe('nested-field', function () { this.beforeEach('visit', () => { - cy.visit('/examples/e2e/nested-field.html') + cy.visit('/examples/e2e/nested-field.html'); }); it('nested-[field]', () => { // data-src in solid-display pointed on skill-*.jsonld - cy.get('#display-skills > div').children().eq(0) + cy.get('#display-skills > div') + .children() + .eq(0) .should('have.attr', 'data-src', '/examples/data/list/skill-2.jsonld'); - cy.get('#display-skills > div').children().eq(1) - .should('have.attr','data-src', '/examples/data/list/skill-3.jsonld'); + cy.get('#display-skills > div') + .children() + .eq(1) + .should('have.attr', 'data-src', '/examples/data/list/skill-3.jsonld'); // User's name not displayed - cy.get('#display-skills > div').children().eq(0) - .find('solid-display-value').should('not.contain.value', 'Test User'); - cy.get('#display-skills > div').children().eq(1) - .find('solid-display-value').should('not.contain.value', 'Test User'); + cy.get('#display-skills > div') + .children() + .eq(0) + .find('solid-display-value') + .should('not.contain.value', 'Test User'); + cy.get('#display-skills > div') + .children() + .eq(1) + .find('solid-display-value') + .should('not.contain.value', 'Test User'); // Skills' name displayed - cy.get('#display-skills > div').children().eq(0) - .find('solid-display-value').should('have.attr', 'value', 'CSS'); - cy.get('#display-skills > div').children().eq(1) - .find('solid-display-value').should('have.attr','value', 'Javascript'); + cy.get('#display-skills > div') + .children() + .eq(0) + .find('solid-display-value') + .should('have.attr', 'value', 'CSS'); + cy.get('#display-skills > div') + .children() + .eq(1) + .find('solid-display-value') + .should('have.attr', 'value', 'Javascript'); }); - it('nested-[field] on related object', () => { // data-src in solid-display pointed on skill-*.jsonld - cy.get('#display-job-skills > div').children().eq(0) + cy.get('#display-job-skills > div') + .children() + .eq(0) .should('have.attr', 'data-src', '/examples/data/list/skill-1.jsonld'); - cy.get('#display-job-skills > div').children().eq(1) - .should('have.attr','data-src', '/examples/data/list/skill-4.jsonld'); + cy.get('#display-job-skills > div') + .children() + .eq(1) + .should('have.attr', 'data-src', '/examples/data/list/skill-4.jsonld'); // User's name not displayed - cy.get('#display-job-skills > div').children().eq(0) - .find('solid-display-value').should('not.contain.value', 'Test User'); - cy.get('#display-job-skills > div').children().eq(1) - .find('solid-display-value').should('not.contain.value', 'Test User'); + cy.get('#display-job-skills > div') + .children() + .eq(0) + .find('solid-display-value') + .should('not.contain.value', 'Test User'); + cy.get('#display-job-skills > div') + .children() + .eq(1) + .find('solid-display-value') + .should('not.contain.value', 'Test User'); // Skills' name displayed - cy.get('#display-job-skills > div').children().eq(0) - .find('solid-display-value').should('have.attr', 'value', 'HTML'); - cy.get('#display-job-skills > div').children().eq(1) - .find('solid-display-value').should('have.attr','value', 'DevOps'); + cy.get('#display-job-skills > div') + .children() + .eq(0) + .find('solid-display-value') + .should('have.attr', 'value', 'HTML'); + cy.get('#display-job-skills > div') + .children() + .eq(1) + .find('solid-display-value') + .should('have.attr', 'value', 'DevOps'); }); - }); diff --git a/cypress/e2e/e2e/next.cy.ts b/cypress/e2e/e2e/next.cy.ts index 576b2431..c598d578 100644 --- a/cypress/e2e/e2e/next.cy.ts +++ b/cypress/e2e/e2e/next.cy.ts @@ -1,21 +1,24 @@ // TODO: We should make tests run independently of one another -describe('next', { testIsolation: false }, function() { +describe('next', { testIsolation: false }, function () { this.beforeAll('visit', () => { - cy.visit('/examples/e2e/next.html') + cy.visit('/examples/e2e/next.html'); }); it('goes to next', () => { cy.get('#list-1 > div').as('list'); - cy.get('@list').children() - .should('have.length', 8); + cy.get('@list').children().should('have.length', 8); // Check next in solid-display cy.get('@list').contains('PHP').click(); - cy.get('#detail > div').should('be.visible').should('contain', '/examples/data/list/skill-5.jsonld') - cy.location().should((loc) => { - expect(loc.hash).to.eq('#view/@%2Fexamples%2Fdata%2Flist%2Fskill-5.jsonld@') - }) + cy.get('#detail > div') + .should('be.visible') + .should('contain', '/examples/data/list/skill-5.jsonld'); + cy.location().should(loc => { + expect(loc.hash).to.eq( + '#view/@%2Fexamples%2Fdata%2Flist%2Fskill-5.jsonld@', + ); + }); }); it('uses the right id with nested components', () => { @@ -23,18 +26,26 @@ describe('next', { testIsolation: false }, function() { // Check next in solid-display cy.get('@list').contains('CSS').click(); - cy.get('#user-detail > div').should('be.visible').should('contain', '/examples/data/list/user-1.jsonld') - cy.location().should((loc) => { - expect(loc.hash).to.eq('#user/@%2Fexamples%2Fdata%2Flist%2Fuser-1.jsonld@') - }) + cy.get('#user-detail > div') + .should('be.visible') + .should('contain', '/examples/data/list/user-1.jsonld'); + cy.location().should(loc => { + expect(loc.hash).to.eq( + '#user/@%2Fexamples%2Fdata%2Flist%2Fuser-1.jsonld@', + ); + }); }); // Check next mixin on solid-display with keyboard it('next mixin accessibility', () => { cy.get('body').tab().tab().type('{enter}'); //.tab() from plugin to use tab keypress - cy.get('#detail > div').should('be.visible').should('contain', '/examples/data/list/skill-2.jsonld') - cy.location().should((loc) => { - expect(loc.hash).to.eq('#view/@%2Fexamples%2Fdata%2Flist%2Fskill-2.jsonld@') - }) + cy.get('#detail > div') + .should('be.visible') + .should('contain', '/examples/data/list/skill-2.jsonld'); + cy.location().should(loc => { + expect(loc.hash).to.eq( + '#view/@%2Fexamples%2Fdata%2Flist%2Fskill-2.jsonld@', + ); + }); }); -}) \ No newline at end of file +}); diff --git a/cypress/e2e/e2e/no-render.cy.ts b/cypress/e2e/e2e/no-render.cy.ts index 8bf53b44..6605910e 100644 --- a/cypress/e2e/e2e/no-render.cy.ts +++ b/cypress/e2e/e2e/no-render.cy.ts @@ -1,4 +1,4 @@ -describe('no-render', function() { +describe('no-render', function () { let win: Window; this.beforeEach('visit', () => { @@ -7,20 +7,22 @@ describe('no-render', function() { win = w; }); }); - + it('blocks rendering', () => { cy.spy(win.sibStore, 'fetchData'); - cy.get('#list').as('list') + cy.get('#list').as('list'); cy.wait(500); - cy.get('@list').children() - .should('have.length', 0); + cy.get('@list').children().should('have.length', 0); cy.get('@list').then($el => { expect(win.sibStore.fetchData).to.have.callCount(0); $el.removeAttr('no-render'); - cy.get('@list').find(' > div').children() - .should('have.length', 8).then(() => { + cy.get('@list') + .find(' > div') + .children() + .should('have.length', 8) + .then(() => { expect(win.sibStore.fetchData).to.be.called; }); }); @@ -29,30 +31,30 @@ describe('no-render', function() { it('blocks nested rendering', () => { cy.spy(win.sibStore, 'fetchData'); - cy.get('#nested-list').as('list') + cy.get('#nested-list').as('list'); cy.wait(500); - cy.get('@list').children() - .should('have.length', 0); + cy.get('@list').children().should('have.length', 0); cy.get('@list').then($el => { expect(win.sibStore.fetchData).to.have.callCount(0); $el.removeAttr('no-render'); - cy.get('@list').find(' > div').children() - .should('have.length', 4).then(() => { + cy.get('@list') + .find(' > div') + .children() + .should('have.length', 4) + .then(() => { expect(win.sibStore.fetchData).to.be.called; }); }); }); it('blocks rendering if no data-src', () => { - cy.get('#form').as('form') + cy.get('#form').as('form'); cy.wait(500); - cy.get('@form').children() - .should('have.length', 0); + cy.get('@form').children().should('have.length', 0); - cy.get('#form-search').as('form-search') - cy.wait(500); - cy.get('@form-search').children() - .should('have.length', 0); + cy.get('#form-search').as('form-search'); + cy.wait(500); + cy.get('@form-search').children().should('have.length', 0); }); -}) \ No newline at end of file +}); diff --git a/cypress/e2e/e2e/order-by.cy.ts b/cypress/e2e/e2e/order-by.cy.ts index 33403a83..5565ce08 100644 --- a/cypress/e2e/e2e/order-by.cy.ts +++ b/cypress/e2e/e2e/order-by.cy.ts @@ -1,92 +1,128 @@ // TODO: We should make tests run independently of one another -describe('order-by', { testIsolation: false }, function() { +describe('order-by', { testIsolation: false }, function () { this.beforeAll('visit', () => { - cy.visit('/examples/e2e/order-by.html') + cy.visit('/examples/e2e/order-by.html'); }); /** - * Order-asc - */ + * Order-asc + */ it('order-asc', () => { cy.get('#list-1 > div').as('list'); - cy.get('@list').children() - .should('have.length', 8); + cy.get('@list').children().should('have.length', 8); // Check elements order - cy.get('@list').find('solid-display').eq(0) - .should('have.attr', 'data-src', '/examples/data/list/skill-2.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-2.jsonld'); - cy.get('solid-display-value[name="name"]').contains('CSS'); - }); - - cy.get('@list').find('solid-display').eq(1) - .should('have.attr', 'data-src', '/examples/data/list/skill-4.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-4.jsonld'); - cy.get('solid-display-value[name="name"]').contains('DevOps'); - }); - - cy.get('@list').find('solid-display').eq(2) - .should('have.attr', 'data-src', '/examples/data/list/skill-6.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-6.jsonld'); - cy.get('solid-display-value[name="name"]').contains('Git'); - }); - - cy.get('@list').find('solid-display').eq(3) - .should('have.attr', 'data-src', '/examples/data/list/skill-1.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-1.jsonld'); - cy.get('solid-display-value[name="name"]').contains('HTML'); - }); - - cy.get('@list').find('solid-display').eq(4) - .should('have.attr', 'data-src', '/examples/data/list/skill-3.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-3.jsonld'); - cy.get('solid-display-value[name="name"]').contains('Javascript'); - }); - - cy.get('@list').find('solid-display').eq(5) - .should('have.attr', 'data-src', '/examples/data/list/skill-8.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-8.jsonld'); - cy.get('solid-display-value[name="name"]').contains('Node'); - }); - - cy.get('@list').find('solid-display').eq(6) - .should('have.attr', 'data-src', '/examples/data/list/skill-5.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-5.jsonld'); - cy.get('solid-display-value[name="name"]').contains('PHP'); - }); - - cy.get('@list').find('solid-display').eq(7) - .should('have.attr', 'data-src', '/examples/data/list/skill-7.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-7.jsonld'); - cy.get('solid-display-value[name="name"]').contains('Python'); - }); + cy.get('@list') + .find('solid-display') + .eq(0) + .should('have.attr', 'data-src', '/examples/data/list/skill-2.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-2.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('CSS'); + }); + + cy.get('@list') + .find('solid-display') + .eq(1) + .should('have.attr', 'data-src', '/examples/data/list/skill-4.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-4.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('DevOps'); + }); + + cy.get('@list') + .find('solid-display') + .eq(2) + .should('have.attr', 'data-src', '/examples/data/list/skill-6.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-6.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('Git'); + }); + + cy.get('@list') + .find('solid-display') + .eq(3) + .should('have.attr', 'data-src', '/examples/data/list/skill-1.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-1.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('HTML'); + }); + + cy.get('@list') + .find('solid-display') + .eq(4) + .should('have.attr', 'data-src', '/examples/data/list/skill-3.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-3.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('Javascript'); + }); + + cy.get('@list') + .find('solid-display') + .eq(5) + .should('have.attr', 'data-src', '/examples/data/list/skill-8.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-8.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('Node'); + }); + + cy.get('@list') + .find('solid-display') + .eq(6) + .should('have.attr', 'data-src', '/examples/data/list/skill-5.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-5.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('PHP'); + }); + + cy.get('@list') + .find('solid-display') + .eq(7) + .should('have.attr', 'data-src', '/examples/data/list/skill-7.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-7.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('Python'); + }); }); /** - * order-by-random - */ + * order-by-random + */ it('sorts resources by random', () => { cy.get('#list-2').as('list'); - cy.get('@list').find('> div').children() - .should('have.length', 8); - - cy.get('@list').find('> div > solid-display').then($div => { - let currentOrder = Array.from($div.map((_index, el) => el.dataset.src)) - cy.get('#reloadList').click(); - cy.get('@list').find('> div > solid-display').then($newDiv => { - let newOrder = Array.from($newDiv.map((_index, el) => el.dataset.src)) - expect(currentOrder).to.not.include.ordered.members(newOrder); - }) - }); + cy.get('@list').find('> div').children().should('have.length', 8); + + cy.get('@list') + .find('> div > solid-display') + .then($div => { + let currentOrder = Array.from($div.map((_index, el) => el.dataset.src)); + cy.get('#reloadList').click(); + cy.get('@list') + .find('> div > solid-display') + .then($newDiv => { + let newOrder = Array.from( + $newDiv.map((_index, el) => el.dataset.src), + ); + expect(currentOrder).to.not.include.ordered.members(newOrder); + }); + }); }); /** @@ -95,64 +131,95 @@ describe('order-by', { testIsolation: false }, function() { it('order-desc', () => { cy.get('#list-3 > div').as('list'); - cy.get('@list').children() - .should('have.length', 8); + cy.get('@list').children().should('have.length', 8); // Check elements order - cy.get('@list').find('solid-display').eq(0) - .should('have.attr', 'data-src', '/examples/data/list/skill-7.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-7.jsonld'); - cy.get('solid-display-value[name="name"]').contains('Python'); - }); - - cy.get('@list').find('solid-display').eq(1) - .should('have.attr', 'data-src', '/examples/data/list/skill-5.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-5.jsonld'); - cy.get('solid-display-value[name="name"]').contains('PHP'); - }); - - cy.get('@list').find('solid-display').eq(2) - .should('have.attr', 'data-src', '/examples/data/list/skill-8.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-8.jsonld'); - cy.get('solid-display-value[name="name"]').contains('Node'); - }); - - cy.get('@list').find('solid-display').eq(3) - .should('have.attr', 'data-src', '/examples/data/list/skill-3.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-3.jsonld'); - cy.get('solid-display-value[name="name"]').contains('Javascript'); - }); - - cy.get('@list').find('solid-display').eq(4) - .should('have.attr', 'data-src', '/examples/data/list/skill-1.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-1.jsonld'); - cy.get('solid-display-value[name="name"]').contains('HTML'); - }); - - cy.get('@list').find('solid-display').eq(5) - .should('have.attr', 'data-src', '/examples/data/list/skill-6.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-6.jsonld'); - cy.get('solid-display-value[name="name"]').contains('Git'); - }); - - cy.get('@list').find('solid-display').eq(6) - .should('have.attr', 'data-src', '/examples/data/list/skill-4.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-4.jsonld'); - cy.get('solid-display-value[name="name"]').contains('DevOps'); - }); - - cy.get('@list').find('solid-display').eq(7) - .should('have.attr', 'data-src', '/examples/data/list/skill-2.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-2.jsonld'); - cy.get('solid-display-value[name="name"]').contains('CSS'); - }); + cy.get('@list') + .find('solid-display') + .eq(0) + .should('have.attr', 'data-src', '/examples/data/list/skill-7.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-7.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('Python'); + }); + + cy.get('@list') + .find('solid-display') + .eq(1) + .should('have.attr', 'data-src', '/examples/data/list/skill-5.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-5.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('PHP'); + }); + + cy.get('@list') + .find('solid-display') + .eq(2) + .should('have.attr', 'data-src', '/examples/data/list/skill-8.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-8.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('Node'); + }); + + cy.get('@list') + .find('solid-display') + .eq(3) + .should('have.attr', 'data-src', '/examples/data/list/skill-3.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-3.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('Javascript'); + }); + + cy.get('@list') + .find('solid-display') + .eq(4) + .should('have.attr', 'data-src', '/examples/data/list/skill-1.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-1.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('HTML'); + }); + + cy.get('@list') + .find('solid-display') + .eq(5) + .should('have.attr', 'data-src', '/examples/data/list/skill-6.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-6.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('Git'); + }); + + cy.get('@list') + .find('solid-display') + .eq(6) + .should('have.attr', 'data-src', '/examples/data/list/skill-4.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-4.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('DevOps'); + }); + + cy.get('@list') + .find('solid-display') + .eq(7) + .should('have.attr', 'data-src', '/examples/data/list/skill-2.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-2.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('CSS'); + }); }); /** @@ -160,64 +227,95 @@ describe('order-by', { testIsolation: false }, function() { */ it('number', () => { cy.get('#list-4 > div').as('list'); - cy.get('@list').children() - .should('have.length', 8); + cy.get('@list').children().should('have.length', 8); // Check elements order - cy.get('@list').find('solid-display').eq(0) - .should('have.attr', 'data-src', '/examples/data/list/skill-1.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-1.jsonld'); - cy.get('solid-display-value[name="name"]').contains('HTML'); - }); - - cy.get('@list').find('solid-display').eq(1) - .should('have.attr', 'data-src', '/examples/data/list/skill-3.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-3.jsonld'); - cy.get('solid-display-value[name="name"]').contains('Javascript'); - }); - - cy.get('@list').find('solid-display').eq(2) - .should('have.attr', 'data-src', '/examples/data/list/skill-2.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-2.jsonld'); - cy.get('solid-display-value[name="name"]').contains('CSS'); - }); - - cy.get('@list').find('solid-display').eq(3) - .should('have.attr', 'data-src', '/examples/data/list/skill-4.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-4.jsonld'); - cy.get('solid-display-value[name="name"]').contains('DevOps'); - }); - - cy.get('@list').find('solid-display').eq(4) - .should('have.attr', 'data-src', '/examples/data/list/skill-5.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-5.jsonld'); - cy.get('solid-display-value[name="name"]').contains('PHP'); - }); - - cy.get('@list').find('solid-display').eq(5) - .should('have.attr', 'data-src', '/examples/data/list/skill-6.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-6.jsonld'); - cy.get('solid-display-value[name="name"]').contains('Git'); - }); - - cy.get('@list').find('solid-display').eq(6) - .should('have.attr', 'data-src', '/examples/data/list/skill-7.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-7.jsonld'); - cy.get('solid-display-value[name="name"]').contains('Python'); - }); - - cy.get('@list').find('solid-display').eq(7) - .should('have.attr', 'data-src', '/examples/data/list/skill-8.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-8.jsonld'); - cy.get('solid-display-value[name="name"]').contains('Node'); - }); + cy.get('@list') + .find('solid-display') + .eq(0) + .should('have.attr', 'data-src', '/examples/data/list/skill-1.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-1.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('HTML'); + }); + + cy.get('@list') + .find('solid-display') + .eq(1) + .should('have.attr', 'data-src', '/examples/data/list/skill-3.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-3.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('Javascript'); + }); + + cy.get('@list') + .find('solid-display') + .eq(2) + .should('have.attr', 'data-src', '/examples/data/list/skill-2.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-2.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('CSS'); + }); + + cy.get('@list') + .find('solid-display') + .eq(3) + .should('have.attr', 'data-src', '/examples/data/list/skill-4.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-4.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('DevOps'); + }); + + cy.get('@list') + .find('solid-display') + .eq(4) + .should('have.attr', 'data-src', '/examples/data/list/skill-5.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-5.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('PHP'); + }); + + cy.get('@list') + .find('solid-display') + .eq(5) + .should('have.attr', 'data-src', '/examples/data/list/skill-6.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-6.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('Git'); + }); + + cy.get('@list') + .find('solid-display') + .eq(6) + .should('have.attr', 'data-src', '/examples/data/list/skill-7.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-7.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('Python'); + }); + + cy.get('@list') + .find('solid-display') + .eq(7) + .should('have.attr', 'data-src', '/examples/data/list/skill-8.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-8.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('Node'); + }); }); /** @@ -226,64 +324,95 @@ describe('order-by', { testIsolation: false }, function() { it('order-by', () => { cy.get('#list-5 > div').as('list'); - cy.get('@list').children() - .should('have.length', 8); + cy.get('@list').children().should('have.length', 8); // Check elements order - cy.get('@list').find('solid-display').eq(0) - .should('have.attr', 'data-src', '/examples/data/list/skill-2.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-2.jsonld'); - cy.get('solid-display-value[name="name"]').contains('CSS'); - }); - - cy.get('@list').find('solid-display').eq(1) - .should('have.attr', 'data-src', '/examples/data/list/skill-4.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-4.jsonld'); - cy.get('solid-display-value[name="name"]').contains('DevOps'); - }); - - cy.get('@list').find('solid-display').eq(2) - .should('have.attr', 'data-src', '/examples/data/list/skill-6.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-6.jsonld'); - cy.get('solid-display-value[name="name"]').contains('Git'); - }); - - cy.get('@list').find('solid-display').eq(3) - .should('have.attr', 'data-src', '/examples/data/list/skill-1.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-1.jsonld'); - cy.get('solid-display-value[name="name"]').contains('HTML'); - }); - - cy.get('@list').find('solid-display').eq(4) - .should('have.attr', 'data-src', '/examples/data/list/skill-3.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-3.jsonld'); - cy.get('solid-display-value[name="name"]').contains('Javascript'); - }); - - cy.get('@list').find('solid-display').eq(5) - .should('have.attr', 'data-src', '/examples/data/list/skill-8.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-8.jsonld'); - cy.get('solid-display-value[name="name"]').contains('Node'); - }); - - cy.get('@list').find('solid-display').eq(6) - .should('have.attr', 'data-src', '/examples/data/list/skill-5.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-5.jsonld'); - cy.get('solid-display-value[name="name"]').contains('PHP'); - }); - - cy.get('@list').find('solid-display').eq(7) - .should('have.attr', 'data-src', '/examples/data/list/skill-7.jsonld') - .within(() => { - cy.get('solid-display-value[name="@id"]').contains('/examples/data/list/skill-7.jsonld'); - cy.get('solid-display-value[name="name"]').contains('Python'); - }); + cy.get('@list') + .find('solid-display') + .eq(0) + .should('have.attr', 'data-src', '/examples/data/list/skill-2.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-2.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('CSS'); + }); + + cy.get('@list') + .find('solid-display') + .eq(1) + .should('have.attr', 'data-src', '/examples/data/list/skill-4.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-4.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('DevOps'); + }); + + cy.get('@list') + .find('solid-display') + .eq(2) + .should('have.attr', 'data-src', '/examples/data/list/skill-6.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-6.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('Git'); + }); + + cy.get('@list') + .find('solid-display') + .eq(3) + .should('have.attr', 'data-src', '/examples/data/list/skill-1.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-1.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('HTML'); + }); + + cy.get('@list') + .find('solid-display') + .eq(4) + .should('have.attr', 'data-src', '/examples/data/list/skill-3.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-3.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('Javascript'); + }); + + cy.get('@list') + .find('solid-display') + .eq(5) + .should('have.attr', 'data-src', '/examples/data/list/skill-8.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-8.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('Node'); + }); + + cy.get('@list') + .find('solid-display') + .eq(6) + .should('have.attr', 'data-src', '/examples/data/list/skill-5.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-5.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('PHP'); + }); + + cy.get('@list') + .find('solid-display') + .eq(7) + .should('have.attr', 'data-src', '/examples/data/list/skill-7.jsonld') + .within(() => { + cy.get('solid-display-value[name="@id"]').contains( + '/examples/data/list/skill-7.jsonld', + ); + cy.get('solid-display-value[name="name"]').contains('Python'); + }); }); /** @@ -293,17 +422,41 @@ describe('order-by', { testIsolation: false }, function() { cy.get('#sorter select[name="field"]').select('username'); cy.get('#sorter select[name="order"]').select('desc'); cy.get('#list-6 > div').children().should('have.length', 4); - cy.get('#list-6 > div').children().eq(0).should('have.attr', 'data-src', '/examples/data/list/user-4.jsonld'); - cy.get('#list-6 > div').children().eq(1).should('have.attr', 'data-src', '/examples/data/list/user-2.jsonld'); - cy.get('#list-6 > div').children().eq(2).should('have.attr', 'data-src', '/examples/data/list/user-3.jsonld'); - cy.get('#list-6 > div').children().eq(3).should('have.attr', 'data-src', '/examples/data/list/user-1.jsonld'); + cy.get('#list-6 > div') + .children() + .eq(0) + .should('have.attr', 'data-src', '/examples/data/list/user-4.jsonld'); + cy.get('#list-6 > div') + .children() + .eq(1) + .should('have.attr', 'data-src', '/examples/data/list/user-2.jsonld'); + cy.get('#list-6 > div') + .children() + .eq(2) + .should('have.attr', 'data-src', '/examples/data/list/user-3.jsonld'); + cy.get('#list-6 > div') + .children() + .eq(3) + .should('have.attr', 'data-src', '/examples/data/list/user-1.jsonld'); cy.get('#sorter select[name="field"]').select('email'); cy.get('#sorter select[name="order"]').select('asc'); cy.get('#list-6 > div').children().should('have.length', 4); - cy.get('#list-6 > div').children().eq(0).should('have.attr', 'data-src', '/examples/data/list/user-3.jsonld'); - cy.get('#list-6 > div').children().eq(1).should('have.attr', 'data-src', '/examples/data/list/user-2.jsonld'); - cy.get('#list-6 > div').children().eq(2).should('have.attr', 'data-src', '/examples/data/list/user-4.jsonld'); - cy.get('#list-6 > div').children().eq(3).should('have.attr', 'data-src', '/examples/data/list/user-1.jsonld'); + cy.get('#list-6 > div') + .children() + .eq(0) + .should('have.attr', 'data-src', '/examples/data/list/user-3.jsonld'); + cy.get('#list-6 > div') + .children() + .eq(1) + .should('have.attr', 'data-src', '/examples/data/list/user-2.jsonld'); + cy.get('#list-6 > div') + .children() + .eq(2) + .should('have.attr', 'data-src', '/examples/data/list/user-4.jsonld'); + cy.get('#list-6 > div') + .children() + .eq(3) + .should('have.attr', 'data-src', '/examples/data/list/user-1.jsonld'); }); -}) +}); diff --git a/cypress/e2e/e2e/paginate-by.cy.ts b/cypress/e2e/e2e/paginate-by.cy.ts index bd740a03..194ab6ea 100644 --- a/cypress/e2e/e2e/paginate-by.cy.ts +++ b/cypress/e2e/e2e/paginate-by.cy.ts @@ -1,37 +1,40 @@ // TODO: We should make tests run independently of one another -describe('paginate-by', { testIsolation: false }, function() { +describe('paginate-by', { testIsolation: false }, function () { this.beforeAll('visit', () => { - cy.visit('/examples/e2e/paginate-by.html') + cy.visit('/examples/e2e/paginate-by.html'); }); /** - * Paginates at loading time - */ + * Paginates at loading time + */ it('paginates resources', () => { - cy.get('#list-1 > nav').as('nav') - .should('have.length', 1); + cy.get('#list-1 > nav').as('nav').should('have.length', 1); // Check buttons - cy.get('@nav').find('button[data-id="prev"]') - .should('have.length', 1) - .and('be.disabled'); - cy.get('@nav').find('button[data-id="next"]') - .should('have.length', 1) - .and('not.be.disabled'); + cy.get('@nav') + .find('button[data-id="prev"]') + .should('have.length', 1) + .and('be.disabled'); + cy.get('@nav') + .find('button[data-id="next"]') + .should('have.length', 1) + .and('not.be.disabled'); // Check page infos - cy.get('@nav').find('> span > span:first-child') - .should('have.attr', 'data-id', 'current') - .contains('1'); - - cy.get('@nav').find('> span > span:last-child') - .should('have.attr', 'data-id', 'count') - .contains('2'); + cy.get('@nav') + .find('> span > span:first-child') + .should('have.attr', 'data-id', 'current') + .contains('1'); + + cy.get('@nav') + .find('> span > span:last-child') + .should('have.attr', 'data-id', 'count') + .contains('2'); }); /** - * Navigate between pages - */ + * Navigate between pages + */ it('goes to prev/next page', () => { cy.get('#list-1').as('list'); cy.get('#list-1 > nav').as('nav'); @@ -50,17 +53,13 @@ describe('paginate-by', { testIsolation: false }, function() { cy.get('@list').contains('user-4.jsonld'); // Check pager buttons - cy.get('@nav').find('button[data-id="prev"]') - .should('not.be.disabled'); - cy.get('@nav').find('button[data-id="next"]') - .should('be.disabled'); + cy.get('@nav').find('button[data-id="prev"]').should('not.be.disabled'); + cy.get('@nav').find('button[data-id="next"]').should('be.disabled'); // Check pager infos - cy.get('@nav').find('> span [data-id=current]') - .contains('2'); + cy.get('@nav').find('> span [data-id=current]').contains('2'); - cy.get('@nav').find('> span [data-id=count]') - .contains('2'); + cy.get('@nav').find('> span [data-id=count]').contains('2'); // Click prev cy.get('@nav').find('button[data-id="prev"]').click(); @@ -71,22 +70,18 @@ describe('paginate-by', { testIsolation: false }, function() { cy.get('@list').contains('user-4.jsonld').should('not.exist'); // Check pager buttons - cy.get('@nav').find('button[data-id="prev"]') - .should('be.disabled'); - cy.get('@nav').find('button[data-id="next"]') - .should('not.be.disabled'); + cy.get('@nav').find('button[data-id="prev"]').should('be.disabled'); + cy.get('@nav').find('button[data-id="next"]').should('not.be.disabled'); // Check pager infos - cy.get('@nav').find('> span [data-id=current]') - .contains('1'); + cy.get('@nav').find('> span [data-id=current]').contains('1'); - cy.get('@nav').find('> span [data-id=count]') - .contains('2'); + cy.get('@nav').find('> span [data-id=count]').contains('2'); }); /** - * Pagination loop - */ + * Pagination loop + */ it('loops pagination', () => { cy.get('#list-2').as('list'); cy.get('#list-2 > nav').as('nav'); @@ -105,17 +100,13 @@ describe('paginate-by', { testIsolation: false }, function() { cy.get('@list').contains('user-4.jsonld'); // Check pager buttons - cy.get('@nav').find('button[data-id="prev"]') - .should('not.be.disabled'); - cy.get('@nav').find('button[data-id="next"]') - .should('not.be.disabled'); + cy.get('@nav').find('button[data-id="prev"]').should('not.be.disabled'); + cy.get('@nav').find('button[data-id="next"]').should('not.be.disabled'); // Check pager infos - cy.get('@nav').find('> span [data-id=current]') - .contains('2'); + cy.get('@nav').find('> span [data-id=current]').contains('2'); - cy.get('@nav').find('> span [data-id=count]') - .contains('2'); + cy.get('@nav').find('> span [data-id=count]').contains('2'); // Click next again cy.get('@nav').find('button[data-id="next"]').click(); @@ -126,17 +117,13 @@ describe('paginate-by', { testIsolation: false }, function() { cy.get('@list').contains('user-4.jsonld').should('not.exist'); // Check pager buttons - cy.get('@nav').find('button[data-id="prev"]') - .should('not.be.disabled'); - cy.get('@nav').find('button[data-id="next"]') - .should('not.be.disabled'); + cy.get('@nav').find('button[data-id="prev"]').should('not.be.disabled'); + cy.get('@nav').find('button[data-id="next"]').should('not.be.disabled'); // Check pager infos - cy.get('@nav').find('> span [data-id=current]') - .contains('1'); + cy.get('@nav').find('> span [data-id=current]').contains('1'); - cy.get('@nav').find('> span [data-id=count]') - .contains('2'); + cy.get('@nav').find('> span [data-id=count]').contains('2'); // Click previous cy.get('@nav').find('button[data-id="prev"]').click(); @@ -147,22 +134,18 @@ describe('paginate-by', { testIsolation: false }, function() { cy.get('@list').contains('user-4.jsonld'); // Check pager buttons - cy.get('@nav').find('button[data-id="prev"]') - .should('not.be.disabled'); - cy.get('@nav').find('button[data-id="next"]') - .should('not.be.disabled'); + cy.get('@nav').find('button[data-id="prev"]').should('not.be.disabled'); + cy.get('@nav').find('button[data-id="next"]').should('not.be.disabled'); // Check pager infos - cy.get('@nav').find('> span [data-id=current]') - .contains('2'); + cy.get('@nav').find('> span [data-id=current]').contains('2'); - cy.get('@nav').find('> span [data-id=count]') - .contains('2'); + cy.get('@nav').find('> span [data-id=count]').contains('2'); }); /** - * Paginate and search - */ + * Paginate and search + */ it('search and paginate', () => { cy.get('#list-3').as('list'); cy.get('@list').find('button[data-id="next"]').click(); @@ -182,4 +165,4 @@ describe('paginate-by', { testIsolation: false }, function() { cy.get('#list-3 > nav').should('be.hidden'); }); -}) +}); diff --git a/cypress/e2e/e2e/reactivity-e2e.cy.ts b/cypress/e2e/e2e/reactivity-e2e.cy.ts index 08934383..ed42d024 100644 --- a/cypress/e2e/e2e/reactivity-e2e.cy.ts +++ b/cypress/e2e/e2e/reactivity-e2e.cy.ts @@ -2,209 +2,279 @@ describe('Reactivity e2e test2', { testIsolation: false }, function () { this.beforeAll('visit', () => { cy.intercept('GET', 'https://ldp-server2.test/users/', { - fixture: "users-nantes.jsonld" - }) + fixture: 'users-nantes.jsonld', + }); cy.intercept('GET', 'https://ldp-server.test/users/', { - fixture: "users-paris.jsonld" - }) + fixture: 'users-paris.jsonld', + }); cy.intercept('GET', '**/sources/users/', { - fixture: "users-source.jsonld" - }) + fixture: 'users-source.jsonld', + }); cy.intercept('GET', '**/users/matthieu/', { - fixture: "users-matthieu.jsonld" - }) + fixture: 'users-matthieu.jsonld', + }); cy.intercept('GET', '**/users/matthieu/circles/', { - fixture: "users-matthieu-circles.jsonld" - }) + fixture: 'users-matthieu-circles.jsonld', + }); cy.intercept('GET', '**/profiles/matthieu/', { - fixture: "profiles-matthieu.jsonld" - }) + fixture: 'profiles-matthieu.jsonld', + }); cy.intercept('GET', '**/profiles/jbpasquier/', { - fixture: "profiles-jbpasquier.jsonld" - }) + fixture: 'profiles-jbpasquier.jsonld', + }); cy.intercept('GET', '**/profiles/alex/', { - fixture: "profiles-alex.jsonld" - }) + fixture: 'profiles-alex.jsonld', + }); cy.intercept('GET', '**/circles/16/', { - fixture: "circles-16.jsonld" - }) + fixture: 'circles-16.jsonld', + }); cy.intercept('GET', '**/circles/17/members/', { - fixture: "circles-17-members.jsonld" - }) + fixture: 'circles-17-members.jsonld', + }); cy.visit('/examples/e2e/reactivity-e2e-test.html'); - }) + }); it('check display', () => { cy.intercept('GET', 'https://ldp-server2.test/users/', { - fixture: "users-nantes.jsonld" - }) + fixture: 'users-nantes.jsonld', + }); cy.intercept('GET', 'https://ldp-server.test/users/', { - fixture: "users-paris.jsonld" // add fixture in case everything is not loaded yet - }) - - cy.get('solid-display#user > div > solid-display-value:nth-child(1)').should('have.attr', 'name', 'first_name').should('contain', 'Matthieu'); - cy.get('solid-display#user > div > solid-display-value:nth-child(2)').should('have.attr', 'name', 'last_name').should('contain', 'Fesselier'); - cy.get('solid-display#user > div > solid-display-value:nth-child(3)').should('have.attr', 'name', 'username').should('contain', 'matthieu'); - cy.get('solid-display#user > div > solid-display-value:nth-child(4)').should('have.attr', 'name', 'profile.city').should('contain', 'Rennes'); - cy.get('solid-display#profile > div > solid-display-value:nth-child(1)').should('have.attr', 'name', 'city').should('contain', 'Rennes'); - cy.get('solid-display#circle > div > solid-display-value:nth-child(1)').should('have.attr', 'name', 'owner.profile.city').should('contain', 'Rennes'); - cy.get('solid-display#profile-widget > div > custom-widget').should('have.attr', 'name', 'profile'); - cy.get('solid-display#profile-widget > div > custom-widget > div').should('contain', 'Rennes'); + fixture: 'users-paris.jsonld', // add fixture in case everything is not loaded yet + }); + + cy.get('solid-display#user > div > solid-display-value:nth-child(1)') + .should('have.attr', 'name', 'first_name') + .should('contain', 'Matthieu'); + cy.get('solid-display#user > div > solid-display-value:nth-child(2)') + .should('have.attr', 'name', 'last_name') + .should('contain', 'Fesselier'); + cy.get('solid-display#user > div > solid-display-value:nth-child(3)') + .should('have.attr', 'name', 'username') + .should('contain', 'matthieu'); + cy.get('solid-display#user > div > solid-display-value:nth-child(4)') + .should('have.attr', 'name', 'profile.city') + .should('contain', 'Rennes'); + cy.get('solid-display#profile > div > solid-display-value:nth-child(1)') + .should('have.attr', 'name', 'city') + .should('contain', 'Rennes'); + cy.get('solid-display#circle > div > solid-display-value:nth-child(1)') + .should('have.attr', 'name', 'owner.profile.city') + .should('contain', 'Rennes'); + cy.get('solid-display#profile-widget > div > custom-widget').should( + 'have.attr', + 'name', + 'profile', + ); + cy.get('solid-display#profile-widget > div > custom-widget > div').should( + 'contain', + 'Rennes', + ); cy.get('solid-display#federation solid-display').should('have.length', 3); cy.get('solid-display#circles-user solid-display').should('have.length', 1); }); it('has reactive nested resources', () => { - cy.intercept("PATCH", '**/profiles/matthieu/', - { + cy.intercept('PATCH', '**/profiles/matthieu/', { headers: { - "content-type": "application/ld+json" + 'content-type': 'application/ld+json', }, - }) + }); - cy.intercept("PATCH", '**/users/matthieu/', - { + cy.intercept('PATCH', '**/users/matthieu/', { headers: { - "content-type": "application/ld+json" + 'content-type': 'application/ld+json', }, - }) - - cy.intercept("GET", '**/users/matthieu/', { - fixture: "users-matthieu.jsonld" - }) - cy.intercept("GET", '**/profiles/matthieu/', { - fixture: "profiles-matthieu-edited.jsonld" - }) - cy.intercept("GET", '**/sources/users/', { - fixture: "users-source.jsonld" - }) - cy.intercept("GET", 'https://ldp-server.test/users/', { - fixture: "users-paris.jsonld" - }) - cy.intercept("GET", 'https://ldp-server2.test/users/', { - fixture: "users-nantes.jsonld" - }) + }); + + cy.intercept('GET', '**/users/matthieu/', { + fixture: 'users-matthieu.jsonld', + }); + cy.intercept('GET', '**/profiles/matthieu/', { + fixture: 'profiles-matthieu-edited.jsonld', + }); + cy.intercept('GET', '**/sources/users/', { + fixture: 'users-source.jsonld', + }); + cy.intercept('GET', 'https://ldp-server.test/users/', { + fixture: 'users-paris.jsonld', + }); + cy.intercept('GET', 'https://ldp-server2.test/users/', { + fixture: 'users-nantes.jsonld', + }); cy.get('solid-form#profile-form input[name="city"]').clear().type('Paris'); cy.get('solid-form#profile-form input[type=submit]').click(); // Nested resource in dot field - cy.get('solid-display#user > div > solid-display-value[name="profile.city"]').should('contain', 'Paris'); + cy.get( + 'solid-display#user > div > solid-display-value[name="profile.city"]', + ).should('contain', 'Paris'); // Nested resource in nested field - cy.get('solid-display#profile > div > solid-display-value[name="city"]').should('contain', 'Paris'); + cy.get( + 'solid-display#profile > div > solid-display-value[name="city"]', + ).should('contain', 'Paris'); // Nested resource in custom widget - cy.get('solid-display#profile-widget > div > custom-widget[name="profile"] > div').should('contain', 'Paris'); + cy.get( + 'solid-display#profile-widget > div > custom-widget[name="profile"] > div', + ).should('contain', 'Paris'); // Nested field in form - cy.intercept("GET", '**/profiles/matthieu/', { - fixture: "profiles-matthieu-edited-2.jsonld" - }) - cy.get('solid-form#user-form-city input[name="profile.city"]').clear().type('Briouze'); + cy.intercept('GET', '**/profiles/matthieu/', { + fixture: 'profiles-matthieu-edited-2.jsonld', + }); + cy.get('solid-form#user-form-city input[name="profile.city"]') + .clear() + .type('Briouze'); cy.get('solid-form#user-form-city input[type=submit]').click(); - cy.get('solid-display#user > div > solid-display-value[name="profile.city"]').should('have.text', 'Briouze'); - cy.get('solid-display#profile > div > solid-display-value[name="city"]').should('have.text', 'Briouze'); - cy.get('solid-display#profile-widget > div > custom-widget[name="profile"] > div').should('have.text', 'Briouze'); + cy.get( + 'solid-display#user > div > solid-display-value[name="profile.city"]', + ).should('have.text', 'Briouze'); + cy.get( + 'solid-display#profile > div > solid-display-value[name="city"]', + ).should('have.text', 'Briouze'); + cy.get( + 'solid-display#profile-widget > div > custom-widget[name="profile"] > div', + ).should('have.text', 'Briouze'); // Nested resource in multi dot field // cy.get('solid-display#circle > solid-display-value[name="owner.profile.city"]').should('contain', 'Paris'); DOES NOT WORK YET }); it('has reactive properties', () => { - cy.intercept("GET", '**/users/matthieu/', { - fixture: "users-matthieu-edited.jsonld" - }) - cy.intercept("GET", '**/sources/users/', { - fixture: "users-source.jsonld" - }) - cy.intercept("GET", 'https://ldp-server.test/users/', { - fixture: "users-edited.jsonld" - }) - cy.intercept("GET", 'https://ldp-server2.test/users/', { - fixture: "users-nantes.jsonld" - }) - cy.intercept("GET", '**/users/jbpasquier/', { - fixture: "users-jbpasquier.jsonld" - }) + cy.intercept('GET', '**/users/matthieu/', { + fixture: 'users-matthieu-edited.jsonld', + }); + cy.intercept('GET', '**/sources/users/', { + fixture: 'users-source.jsonld', + }); + cy.intercept('GET', 'https://ldp-server.test/users/', { + fixture: 'users-edited.jsonld', + }); + cy.intercept('GET', 'https://ldp-server2.test/users/', { + fixture: 'users-nantes.jsonld', + }); + cy.intercept('GET', '**/users/jbpasquier/', { + fixture: 'users-jbpasquier.jsonld', + }); cy.intercept('GET', '**/profiles/jbpasquier/', { - fixture: "profiles-jbpasquier.jsonld" - }) - cy.intercept("GET", '**/users/alex/', { - fixture: "users-alex.jsonld" - }) + fixture: 'profiles-jbpasquier.jsonld', + }); + cy.intercept('GET', '**/users/alex/', { + fixture: 'users-alex.jsonld', + }); cy.intercept('GET', '**/profiles/alex/', { - fixture: "profiles-alex.jsonld" - }) + fixture: 'profiles-alex.jsonld', + }); - cy.intercept("PATCH", '**/users/matthieu/', { + cy.intercept('PATCH', '**/users/matthieu/', { headers: { - "content-type": "application/ld+json" + 'content-type': 'application/ld+json', }, - }) + }); - cy.intercept("POST", "https://ldp-server.test/users/", { + cy.intercept('POST', 'https://ldp-server.test/users/', { headers: { - "content-type": "application/ld+json" + 'content-type': 'application/ld+json', }, - }) + }); - cy.intercept("DELETE", "**/users/alex/", { + cy.intercept('DELETE', '**/users/alex/', { headers: { - "content-type": "application/ld+json" + 'content-type': 'application/ld+json', }, - }) + }); // Fill matthieu's form - cy.get('solid-form#user-form input[name="first_name"]').clear().type('Test'); + cy.get('solid-form#user-form input[name="first_name"]') + .clear() + .type('Test'); cy.get('solid-form#user-form input[name="last_name"]').clear().type('User'); cy.get('solid-form#user-form input[name="username"]').clear().type('admin'); cy.get('solid-form#user-form input[type=submit]').click(); // Single solid-display - cy.get('solid-display#user > div > solid-display-value[name="first_name"]').should('contain', 'Test'); - cy.get('solid-display#user > div > solid-display-value[name="last_name"]').should('contain', 'User'); - cy.get('solid-display#user > div > solid-display-value[name="username"]').should('contain', 'admin'); + cy.get( + 'solid-display#user > div > solid-display-value[name="first_name"]', + ).should('contain', 'Test'); + cy.get( + 'solid-display#user > div > solid-display-value[name="last_name"]', + ).should('contain', 'User'); + cy.get( + 'solid-display#user > div > solid-display-value[name="username"]', + ).should('contain', 'admin'); // List solid-display & range - const src = "https://ldp-server.test/users/matthieu/"; - cy.get(`solid-display#users solid-display[data-src="${src}"] > div > solid-display-value[name="first_name"]`).should('contain', 'Test'); - cy.get(`solid-display#users solid-display[data-src="${src}"] > div > solid-display-value[name="last_name"]`).should('contain', 'User'); - cy.get(`solid-display#users solid-display[data-src="${src}"] > div > solid-display-value[name="username"]`).should('contain', 'admin'); - cy.get(`solid-form#range option[value='{"@id": "${src}"}']`).should('contain', 'Test User'); + const src = 'https://ldp-server.test/users/matthieu/'; + cy.get( + `solid-display#users solid-display[data-src="${src}"] > div > solid-display-value[name="first_name"]`, + ).should('contain', 'Test'); + cy.get( + `solid-display#users solid-display[data-src="${src}"] > div > solid-display-value[name="last_name"]`, + ).should('contain', 'User'); + cy.get( + `solid-display#users solid-display[data-src="${src}"] > div > solid-display-value[name="username"]`, + ).should('contain', 'admin'); + cy.get(`solid-form#range option[value='{"@id": "${src}"}']`).should( + 'contain', + 'Test User', + ); // Federation - cy.get(`solid-display#federation solid-display[data-src="${src}"] > div > solid-display-value[name="first_name"]`).should('contain', 'Test'); - cy.get(`solid-display#federation solid-display[data-src="${src}"] > div > solid-display-value[name="last_name"]`).should('contain', 'User'); - cy.get(`solid-display#federation solid-display[data-src="${src}"] > div > solid-display-value[name="username"]`).should('contain', 'admin'); + cy.get( + `solid-display#federation solid-display[data-src="${src}"] > div > solid-display-value[name="first_name"]`, + ).should('contain', 'Test'); + cy.get( + `solid-display#federation solid-display[data-src="${src}"] > div > solid-display-value[name="last_name"]`, + ).should('contain', 'User'); + cy.get( + `solid-display#federation solid-display[data-src="${src}"] > div > solid-display-value[name="username"]`, + ).should('contain', 'admin'); // Fill new user form - cy.get('solid-form#users-form input[name="first_name"]').clear().type('Alex'); - cy.get('solid-form#users-form input[name="last_name"]').clear().type('Bourlier'); + cy.get('solid-form#users-form input[name="first_name"]') + .clear() + .type('Alex'); + cy.get('solid-form#users-form input[name="last_name"]') + .clear() + .type('Bourlier'); cy.get('solid-form#users-form input[name="username"]').clear().type('alex'); cy.get('solid-form#users-form input[type=submit]').click(); // List solid-display & range - const newSrc = "https://ldp-server.test/users/alex/"; + const newSrc = 'https://ldp-server.test/users/alex/'; cy.get(`solid-display#users solid-display`).should('have.length', 3); - cy.get(`solid-display#users solid-display[data-src="${newSrc}"] > div > solid-display-value[name="first_name"]`).should('contain', 'Alex'); - cy.get(`solid-display#users solid-display[data-src="${newSrc}"] > div > solid-display-value[name="last_name"]`).should('contain', 'Bourlier'); - cy.get(`solid-display#users solid-display[data-src="${newSrc}"] > div > solid-display-value[name="username"]`).should('contain', 'alex'); + cy.get( + `solid-display#users solid-display[data-src="${newSrc}"] > div > solid-display-value[name="first_name"]`, + ).should('contain', 'Alex'); + cy.get( + `solid-display#users solid-display[data-src="${newSrc}"] > div > solid-display-value[name="last_name"]`, + ).should('contain', 'Bourlier'); + cy.get( + `solid-display#users solid-display[data-src="${newSrc}"] > div > solid-display-value[name="username"]`, + ).should('contain', 'alex'); cy.get(`solid-form#range option`).should('have.length', 4); // Federation - cy.get(`solid-display#federation solid-display[data-src="${newSrc}"] > div > solid-display-value[name="first_name"]`).should('contain', 'Alex'); - cy.get(`solid-display#federation solid-display[data-src="${newSrc}"] > div > solid-display-value[name="last_name"]`).should('contain', 'Bourlier'); - cy.get(`solid-display#federation solid-display[data-src="${newSrc}"] > div > solid-display-value[name="username"]`).should('contain', 'alex'); + cy.get( + `solid-display#federation solid-display[data-src="${newSrc}"] > div > solid-display-value[name="first_name"]`, + ).should('contain', 'Alex'); + cy.get( + `solid-display#federation solid-display[data-src="${newSrc}"] > div > solid-display-value[name="last_name"]`, + ).should('contain', 'Bourlier'); + cy.get( + `solid-display#federation solid-display[data-src="${newSrc}"] > div > solid-display-value[name="username"]`, + ).should('contain', 'alex'); // delete user & range - cy.intercept("GET", 'https://ldp-server.test/users/', { - fixture: "users-paris.jsonld" - }) + cy.intercept('GET', 'https://ldp-server.test/users/', { + fixture: 'users-paris.jsonld', + }); cy.get('solid-delete#delete-user > button').click(); cy.get(`solid-display#users solid-display`).should('have.length', 2); cy.get(`solid-form#range option`).should('have.length', 3); @@ -212,21 +282,23 @@ describe('Reactivity e2e test2', { testIsolation: false }, function () { }); it('makes virtual containers reactive', () => { - cy.intercept("GET", '**/users/matthieu/circles/', { - fixture: "users-matthieu-circles-edited.jsonld" - }) - cy.intercept("GET", '**/circles/17/members/', { - fixture: "circles-17-members.jsonld" - }) - - cy.intercept("POST", "https://ldp-server.test/circles/17/members/", { + cy.intercept('GET', '**/users/matthieu/circles/', { + fixture: 'users-matthieu-circles-edited.jsonld', + }); + cy.intercept('GET', '**/circles/17/members/', { + fixture: 'circles-17-members.jsonld', + }); + + cy.intercept('POST', 'https://ldp-server.test/circles/17/members/', { headers: { - "content-type": "application/ld+json" + 'content-type': 'application/ld+json', }, - }) + }); - cy.get('solid-form#circles-user-form input[name="name"]').clear().type('New circle'); + cy.get('solid-form#circles-user-form input[name="name"]') + .clear() + .type('New circle'); cy.get('solid-form#circles-user-form input[type=submit]').click(); cy.get('solid-display#circles-user solid-display').should('have.length', 2); }); -}) +}); diff --git a/cypress/e2e/e2e/search.cy.ts b/cypress/e2e/e2e/search.cy.ts index 3e0ba5aa..1340bf5d 100644 --- a/cypress/e2e/e2e/search.cy.ts +++ b/cypress/e2e/e2e/search.cy.ts @@ -1,61 +1,72 @@ // TODO: We should make tests run independently of one another -describe('solid-form-search widget', { testIsolation: false }, function() { +describe('solid-form-search widget', { testIsolation: false }, function () { this.beforeAll('visit', () => { - cy.visit('/examples/e2e/search.html') - }) + cy.visit('/examples/e2e/search.html'); + }); it('solid-form-search', () => { cy.get('solid-form-search#filter1') .find('select') .should('have.attr', 'name', 'username') - .children().and('have.length', 6) + .children() + .and('have.length', 6); cy.get('solid-form-search#filter1') - .find('option').eq(0) + .find('option') + .eq(0) .should('have.attr', 'value', '') .contains('-'); cy.get('solid-form-search#filter1') - .find('option').eq(1) + .find('option') + .eq(1) .should('have.attr', 'value', 'admin') .contains('admin'); - + cy.get('solid-form-search#filter2') .find('select') .should('have.attr', 'name', 'last_name') - .children().and('have.length', 5); + .children() + .and('have.length', 5); cy.get('solid-form-search#filter2') - .find('option').eq(0) + .find('option') + .eq(0) .should('have.attr', 'value', '') .contains('-'); cy.get('solid-form-search#filter2') - .find('option').eq(1) + .find('option') + .eq(1) .should('have.attr', 'value', 'a') .contains('User'); }); it('solid-form-search + submit-button', () => { cy.get('#filter3') - .find('input[type=submit]').as('btn') + .find('input[type=submit]') + .as('btn') .should('have.attr', 'value', 'update result'); cy.get('#filter3 > form').find('div').children('input[type="submit"]'); cy.get('#display3 > div > solid-display').should('have.length', 4); cy.get('#filter3 select').select('User'); cy.get('#display3 > div > solid-display').should('have.length', 4); - cy.get('@btn').click() + cy.get('@btn').click(); cy.get('#display3 > div > solid-display').should('have.length', 1); }); it('solid-form-search + submit-widget', () => { - cy.get('solid-form-search#filter-submit-widget').find('input[type="submit"]') + cy.get('solid-form-search#filter-submit-widget') + .find('input[type="submit"]') .should('not.exist'); - cy.get('solid-form-search#filter-submit-widget').find('button[type="submit"]') + cy.get('solid-form-search#filter-submit-widget') + .find('button[type="submit"]') .should('exist') .and('have.text', 'OK'); }); it('solid-form-search + class-submit-button', () => { cy.get('solid-form-search#filter-class-submit-button') - .find('div').should('have.class', 'button-class') - .find('input').should('exist'); + .find('div') + .should('have.class', 'button-class') + .find('input') + .should('exist'); }); it('solid-form-search + start-value & end-value', () => { @@ -63,15 +74,13 @@ describe('solid-form-search widget', { testIsolation: false }, function() { .find('solid-form-rangedate') .should('have.attr', 'start-value', '2020-06-01') .and('have.attr', 'end-value', '2021-01-12'); - cy.get('#display4 > div ') - .children().should('have.length', 2) + cy.get('#display4 > div ').children().should('have.length', 2); cy.get('#filter5 > form') .find('solid-form-rangenumber') .should('have.attr', 'start-value', '2') .and('have.attr', 'end-value', '10'); - cy.get('#display5 > div ') - .children().should('have.length', 3) + cy.get('#display5 > div ').children().should('have.length', 3); }); it('solid-form-search + search-[field]', () => { @@ -79,28 +88,30 @@ describe('solid-form-search widget', { testIsolation: false }, function() { .find('solid-form-label-text') .should('have.attr', 'name', 'global_name') .find('input') - .type('em') + .type('em'); cy.get('#display-search-field-1 > div') - .children().should('have.length', 1) + .children() + .should('have.length', 1) .filter('solid-display[data-src="/examples/data/list/user-3.jsonld"]'); cy.get('#display-search-field-2 > div') - .children().should('have.length', 1) + .children() + .should('have.length', 1) .filter('solid-display[data-src="/examples/data/list/event-4.jsonld"]'); }); it('solid-form-search + solid-form-hidden', () => { - cy.get('#display-filter-hidden > div') - .children().should('have.length', 2) + cy.get('#display-filter-hidden > div').children().should('have.length', 2); cy.get('#display-filter-hidden-bool > div') - .children().should('have.length', 2) + .children() + .should('have.length', 2); cy.get('#display-filter-hidden-num > div') - .children().should('have.length', 2) + .children() + .should('have.length', 2); }); it('solid-form-search + fakeField', () => { - cy.get('#display-fake-field > div ') - .children().should('have.length', 4) + cy.get('#display-fake-field > div ').children().should('have.length', 4); cy.get('#filter-fake-field > form') .find('solid-form-label-text') @@ -108,90 +119,102 @@ describe('solid-form-search widget', { testIsolation: false }, function() { .find('input') .type('em'); - cy.get('#display-fake-field > div ') - .children().should('have.length', 0) + cy.get('#display-fake-field > div ').children().should('have.length', 0); }); it('solid-form-search + solid-form-hidden', () => { - cy.get('#display-filter-hidden > div') - .children().should('have.length', 2) + cy.get('#display-filter-hidden > div').children().should('have.length', 2); cy.get('#display-filter-hidden-bool > div') - .children().should('have.length', 2) + .children() + .should('have.length', 2); cy.get('#display-filter-hidden-num > div') - .children().should('have.length', 2) + .children() + .should('have.length', 2); }); it('solid-form-search + container', () => { - cy.get('#filter-container > div ') - .children().should('have.length', 4) + cy.get('#filter-container > div ').children().should('have.length', 4); - cy.get('#skill-search > form') - .find('select') - .select('HTML'); + cy.get('#skill-search > form').find('select').select('HTML'); - cy.get('#filter-container > div ') - .children().should('have.length', 2) + cy.get('#filter-container > div ').children().should('have.length', 2); }); it('solid-form-search + subject=null', () => { - cy.get('#display-null-subject solid-display-value[name="profile.available"][value=""]').should('exist') - cy.get('#filter-null-subject input').type("foo") - cy.get('#display-null-subject solid-display-value[name="profile.available"][value=""]').should('not.exist') + cy.get( + '#display-null-subject solid-display-value[name="profile.available"][value=""]', + ).should('exist'); + cy.get('#filter-null-subject input').type('foo'); + cy.get( + '#display-null-subject solid-display-value[name="profile.available"][value=""]', + ).should('not.exist'); }); it('solid-form-search + resource', () => { - cy.get('#display-profile-search > div').children().should('have.length', '1') - cy.get('#display-profile-search > div > solid-display').should('have.attr', 'data-src', '/examples/data/list/user-1.jsonld') + cy.get('#display-profile-search > div') + .children() + .should('have.length', '1'); + cy.get('#display-profile-search > div > solid-display').should( + 'have.attr', + 'data-src', + '/examples/data/list/user-1.jsonld', + ); }); it('solid-form-search + number', () => { - cy.get('#number-search solid-form-label-text[name=username] input').type('123'); - cy.get('#display-number-search > div').children().should('have.length', 0) + cy.get('#number-search solid-form-label-text[name=username] input').type( + '123', + ); + cy.get('#display-number-search > div').children().should('have.length', 0); }); it('solid-form-search + empty-widget', () => { + cy.get('#span-empty-widget > div').children().should('have.length', 4); + cy.get('#filter-with-empty-widget').find('input').type('rrr'); cy.get('#span-empty-widget > div') - .children().should('have.length', 4); - cy.get('#filter-with-empty-widget') - .find('input').type('rrr'); - cy.get('#span-empty-widget > div') - .children().should('have.length', 1) + .children() + .should('have.length', 1) .and('contain', 'Pierre DLC'); - cy.get('#filter-with-empty-widget') - .find('input').type('r'); + cy.get('#filter-with-empty-widget').find('input').type('r'); cy.get('#span-empty-widget > span') - .children().should('have.length', 1) + .children() + .should('have.length', 1) .and('contain', 'No name found'); - cy.get('#filter-with-empty-widget') - .find('input').type('{backspace}'); + cy.get('#filter-with-empty-widget').find('input').type('{backspace}'); cy.get('#span-empty-widget > div') - .children().should('have.length', 1) + .children() + .should('have.length', 1) .and('contain', 'Pierre DLC'); - }) + }); it('solid-form-search + checkboxes', () => { cy.get('#enum-checkboxes-display > div') - .children().should('have.length', 8); + .children() + .should('have.length', 8); cy.get('#enum-checkboxes') - .find('input[value="HTML"]').check({ force: true }); + .find('input[value="HTML"]') + .check({ force: true }); cy.get('#enum-checkboxes-display > div') - .children().should('have.length', 1); + .children() + .should('have.length', 1); cy.get('#enum-checkboxes') - .find('input[value="CSS"]').check({ force: true }); + .find('input[value="CSS"]') + .check({ force: true }); cy.get('#enum-checkboxes-display > div') - .children().should('have.length', 2); - }) + .children() + .should('have.length', 2); + }); it('solid-form-search + debounce', () => { - const input = cy.get('#filter-debounce input') - input.type('p') - cy.wait(1000) - cy.get('#debounce>div>solid-display').should('not.have.length', 4) - input.type('hp') - cy.get('#debounce>div>solid-display').should('have.length', 1) - }) -}) \ No newline at end of file + const input = cy.get('#filter-debounce input'); + input.type('p'); + cy.wait(1000); + cy.get('#debounce>div>solid-display').should('not.have.length', 4); + input.type('hp'); + cy.get('#debounce>div>solid-display').should('have.length', 1); + }); +}); diff --git a/cypress/e2e/e2e/server-pagination.cy.ts b/cypress/e2e/e2e/server-pagination.cy.ts index 34c52c7a..f0dbae8f 100644 --- a/cypress/e2e/e2e/server-pagination.cy.ts +++ b/cypress/e2e/e2e/server-pagination.cy.ts @@ -1,95 +1,112 @@ // TODO: We should make tests run independently of one another describe('server-pagination', { testIsolation: false }, function () { - this.beforeAll('visit', () => { - cy.visit('/examples/e2e/server-pagination.html') - }); - - /** - * Paginates from server - */ - it('paginates resources', () => { - cy.get('#list-1 > nav').as('nav') - .should('have.length', 1); - - // Check buttons - cy.get('@nav').find('button[data-id="prev"]') - .should('have.length', 1) - .and('be.disabled'); - cy.get('@nav').find('button[data-id="next"]') - .should('have.length', 1) - .and('not.be.disabled'); - - // Check page infos - cy.get('@nav').find('> span') - .should('have.attr', 'data-id', 'current') - .contains('1'); - }); - - it('goes to prev/next page', () => { - cy.get('#list-1').as('list'); - cy.get('#list-1 > nav').as('nav'); - - // Click next -> To investigate how to answer paginated responses in the test context (static files) - cy.get('@list').contains('/examples/data/list/--user-0.jsonld'); - cy.get('@list').contains('/examples/data/list/--user-1.jsonld'); - cy.get('@list').contains('/examples/data/list/--user-2.jsonld').should('not.exist'); - cy.get('@list').contains('/examples/data/list/--user-3.jsonld').should('not.exist'); - // cy.get('@list').contains('user-4.jsonld').should('not.exist'); - - cy.get('@nav').find('button[data-id="next"]').click(); - - // Click next -> To investigate how to answer paginated responses in the test context (static files) - cy.get('@list').contains('/examples/data/list/--user-1.jsonld').should('not.exist'); - cy.get('@list').contains('/examples/data/list/--user-0.jsonld').should('not.exist'); - cy.get('@list').contains('/examples/data/list/--user-2.jsonld'); - cy.get('@list').contains('/examples/data/list/--user-3.jsonld'); - - // Check pager buttons - cy.get('@nav').find('button[data-id="prev"]') - .should('not.be.disabled'); - - // Check pager infos - cy.get('@nav').find('> [data-id=current]') - .contains('2'); - - // Click prev - cy.get('@nav').find('button[data-id="prev"]').click(); - - // Check pager buttons - cy.get('@nav').find('button[data-id="prev"]') - .should('be.disabled'); - cy.get('@nav').find('button[data-id="next"]') - .should('not.be.disabled'); - - // Check pager infos - cy.get('@nav').find('> [data-id=current]') - .contains('1'); - }); + this.beforeAll('visit', () => { + cy.visit('/examples/e2e/server-pagination.html'); + }); + + /** + * Paginates from server + */ + it('paginates resources', () => { + cy.get('#list-1 > nav').as('nav').should('have.length', 1); + + // Check buttons + cy.get('@nav') + .find('button[data-id="prev"]') + .should('have.length', 1) + .and('be.disabled'); + cy.get('@nav') + .find('button[data-id="next"]') + .should('have.length', 1) + .and('not.be.disabled'); + + // Check page infos + cy.get('@nav') + .find('> span') + .should('have.attr', 'data-id', 'current') + .contains('1'); + }); + + it('goes to prev/next page', () => { + cy.get('#list-1').as('list'); + cy.get('#list-1 > nav').as('nav'); + + // Click next -> To investigate how to answer paginated responses in the test context (static files) + cy.get('@list').contains('/examples/data/list/--user-0.jsonld'); + cy.get('@list').contains('/examples/data/list/--user-1.jsonld'); + cy.get('@list') + .contains('/examples/data/list/--user-2.jsonld') + .should('not.exist'); + cy.get('@list') + .contains('/examples/data/list/--user-3.jsonld') + .should('not.exist'); + // cy.get('@list').contains('user-4.jsonld').should('not.exist'); + + cy.get('@nav').find('button[data-id="next"]').click(); + + // Click next -> To investigate how to answer paginated responses in the test context (static files) + cy.get('@list') + .contains('/examples/data/list/--user-1.jsonld') + .should('not.exist'); + cy.get('@list') + .contains('/examples/data/list/--user-0.jsonld') + .should('not.exist'); + cy.get('@list').contains('/examples/data/list/--user-2.jsonld'); + cy.get('@list').contains('/examples/data/list/--user-3.jsonld'); + + // Check pager buttons + cy.get('@nav').find('button[data-id="prev"]').should('not.be.disabled'); + + // Check pager infos + cy.get('@nav').find('> [data-id=current]').contains('2'); + + // Click prev + cy.get('@nav').find('button[data-id="prev"]').click(); + + // Check pager buttons + cy.get('@nav').find('button[data-id="prev"]').should('be.disabled'); + cy.get('@nav').find('button[data-id="next"]').should('not.be.disabled'); + + // Check pager infos + cy.get('@nav').find('> [data-id=current]').contains('1'); + }); /** - * Paginate and search client-side - */ + * Paginate and search client-side + */ it('search and paginate', () => { cy.get('#list-2').as('list'); cy.get('@list').contains('/examples/data/list/--user-2.jsonld'); cy.get('@list').contains('/examples/data/list/--user-3.jsonld'); - + cy.get('@list').find('button[data-id="next"]').click(); - cy.get('@list').contains('/examples/data/list/--user-2.jsonld').should('not.exist'); - cy.get('@list').contains('/examples/data/list/--user-3.jsonld').should('not.exist'); + cy.get('@list') + .contains('/examples/data/list/--user-2.jsonld') + .should('not.exist'); + cy.get('@list') + .contains('/examples/data/list/--user-3.jsonld') + .should('not.exist'); cy.get('@list').contains('/examples/data/list/--user-6.jsonld'); cy.get('@list').contains('/examples/data/list/--user-7.jsonld'); - + // search cy.get('#username-form').find('input[name="username"]').type('henry'); - cy.get('@list').contains('/examples/data/list/--user-10.jsonld').should('exist'); - cy.get('@list').contains('/examples/data/list/--user-6.jsonld').should('not.exist'); - cy.get('@list').contains('/examples/data/list/--user-7.jsonld').should('not.exist'); - cy.get('@list').contains('/examples/data/list/--user-8.jsonld').should('not.exist'); + cy.get('@list') + .contains('/examples/data/list/--user-10.jsonld') + .should('exist'); + cy.get('@list') + .contains('/examples/data/list/--user-6.jsonld') + .should('not.exist'); + cy.get('@list') + .contains('/examples/data/list/--user-7.jsonld') + .should('not.exist'); + cy.get('@list') + .contains('/examples/data/list/--user-8.jsonld') + .should('not.exist'); //TODO: Improvement: hide the navigation when searching // cy.get('#list-2 > nav').should('be.hidden'); }); -}); \ No newline at end of file +}); diff --git a/cypress/e2e/e2e/server-search.cy.ts b/cypress/e2e/e2e/server-search.cy.ts index 7da1dce2..a0cd3293 100644 --- a/cypress/e2e/e2e/server-search.cy.ts +++ b/cypress/e2e/e2e/server-search.cy.ts @@ -1,47 +1,49 @@ describe('server-search', function () { - this.beforeEach('visit', () => { - cy.visit('/examples/e2e/server-search.html'); - }) - - /** - * Server Search only test - */ - it('server search', () => { - // Get forms - cy.get("#search-form-1").as('forms'); - - // Check firstname field - cy.get("@forms").find("input[name='first_name']").as('first_name') - cy.get('@first_name').type('Santiago') - - // Start Search - cy.get('@forms').find('input[type="submit"]').as("forms_submit") - cy.get('@forms_submit').click() - - // Check result - cy.get('#result1') - .should('have.attr', 'data-src', '/mock/users.jsonld') - .find('div > solid-display').should('have.length', 1); - }) - - /** - * Server Search with Server pagination test - */ - it('server-search with server-pagination', () => { - // Get forms - cy.get("#search-form-2").as('forms'); - - // Check firstname field - cy.get("@forms").find("input[name='first_name']").as('first_name') - cy.get('@first_name').type('an') - - // Start Search - cy.get('@forms').find('input[type="submit"]').as("forms_submit") - cy.get('@forms_submit').click() - - // Check result - cy.get('#result2') - .should('have.attr', 'data-src', '/mock/users.jsonld') - .find('div > solid-display').should('have.length', 5); - }); -}) \ No newline at end of file + this.beforeEach('visit', () => { + cy.visit('/examples/e2e/server-search.html'); + }); + + /** + * Server Search only test + */ + it('server search', () => { + // Get forms + cy.get('#search-form-1').as('forms'); + + // Check firstname field + cy.get('@forms').find("input[name='first_name']").as('first_name'); + cy.get('@first_name').type('Santiago'); + + // Start Search + cy.get('@forms').find('input[type="submit"]').as('forms_submit'); + cy.get('@forms_submit').click(); + + // Check result + cy.get('#result1') + .should('have.attr', 'data-src', '/mock/users.jsonld') + .find('div > solid-display') + .should('have.length', 1); + }); + + /** + * Server Search with Server pagination test + */ + it('server-search with server-pagination', () => { + // Get forms + cy.get('#search-form-2').as('forms'); + + // Check firstname field + cy.get('@forms').find("input[name='first_name']").as('first_name'); + cy.get('@first_name').type('an'); + + // Start Search + cy.get('@forms').find('input[type="submit"]').as('forms_submit'); + cy.get('@forms_submit').click(); + + // Check result + cy.get('#result2') + .should('have.attr', 'data-src', '/mock/users.jsonld') + .find('div > solid-display') + .should('have.length', 5); + }); +}); diff --git a/cypress/e2e/e2e/sib-register.cy.ts b/cypress/e2e/e2e/sib-register.cy.ts index fb785b1d..d5d82dad 100644 --- a/cypress/e2e/e2e/sib-register.cy.ts +++ b/cypress/e2e/e2e/sib-register.cy.ts @@ -1,4 +1,4 @@ -describe('Component factory', function() { +describe('Component factory', function () { let Sib: typeof import('../../../src/libs/Sib').Sib; let win: Window; let doc: Document; diff --git a/cypress/e2e/e2e/simple-startinblox-e2e.cy.ts b/cypress/e2e/e2e/simple-startinblox-e2e.cy.ts index c45081bc..b6508c70 100644 --- a/cypress/e2e/e2e/simple-startinblox-e2e.cy.ts +++ b/cypress/e2e/e2e/simple-startinblox-e2e.cy.ts @@ -1,15 +1,17 @@ -describe('simple Startin’blox e2e test', function() { +describe('simple Startin’blox e2e test', function () { this.beforeEach('visit', () => { - cy.visit('/examples/e2e/simple-startinblox-e2e-test.html') - }) + cy.visit('/examples/e2e/simple-startinblox-e2e-test.html'); + }); it('check children count', () => { - cy.get('body > solid-display > div').children().should('have.length', 4) - }) + cy.get('body > solid-display > div').children().should('have.length', 4); + }); it('check first children content', () => { - cy.get('body > solid-display > div > solid-display:first-child > div > solid-display-value:first-child') + cy.get( + 'body > solid-display > div > solid-display:first-child > div > solid-display-value:first-child', + ) .should('have.attr', 'name', 'first_name') - .should('contain', 'Test') - }) -}) + .should('contain', 'Test'); + }); +}); diff --git a/cypress/e2e/e2e/solid-ac-checker.cy.ts b/cypress/e2e/e2e/solid-ac-checker.cy.ts index 3c691a36..962b8c83 100644 --- a/cypress/e2e/e2e/solid-ac-checker.cy.ts +++ b/cypress/e2e/e2e/solid-ac-checker.cy.ts @@ -1,6 +1,6 @@ -describe('solid-ac-checker', function() { +describe('solid-ac-checker', function () { this.beforeEach('visit', () => { - cy.visit('/examples/e2e/solid-ac-checker.html') + cy.visit('/examples/e2e/solid-ac-checker.html'); }); it('permission attribute', () => { @@ -20,4 +20,4 @@ describe('solid-ac-checker', function() { cy.get('#ac-checker-3').should('not.have.attr', 'hidden'); cy.get('#test3').should('be.visible'); }); -}) \ No newline at end of file +}); diff --git a/cypress/e2e/e2e/solid-delete.cy.ts b/cypress/e2e/e2e/solid-delete.cy.ts index d95e10cf..f7e986dc 100644 --- a/cypress/e2e/e2e/solid-delete.cy.ts +++ b/cypress/e2e/e2e/solid-delete.cy.ts @@ -11,18 +11,19 @@ describe('solid-delete', function () { it('calls store.delete and send events', () => { cy.spy(win.sibStore, 'delete'); - cy.intercept("DELETE", '**/project.jsonld', - { - statusCode: 204 - }) + cy.intercept('DELETE', '**/project.jsonld', { + statusCode: 204, + }); // button created cy.get('solid-delete#test1').find('button').should('have.length', 1); cy.get('solid-delete#test1 button').should('have.text', 'Supprimer'); // on click, store.delete is called - cy.get('solid-delete#test1 button').click({ force: true }).then(() => { - expect(win.sibStore.delete).to.be.called; - }); + cy.get('solid-delete#test1 button') + .click({ force: true }) + .then(() => { + expect(win.sibStore.delete).to.be.called; + }); // events have been fired cy.get('#res') .should('contain', 'save: /examples/data/project.jsonld') @@ -33,12 +34,11 @@ describe('solid-delete', function () { it('does not send events on failure', () => { cy.reload(); - cy.intercept("DELETE", '**/project.jsonld', - { - statusCode: 403 - }) + cy.intercept('DELETE', '**/project.jsonld', { + statusCode: 403, + }); - cy.get('solid-delete#test1 button').click({ force: true }) + cy.get('solid-delete#test1 button').click({ force: true }); // if server fails, events not fired cy.get('#res').should('be.empty'); }); @@ -46,8 +46,10 @@ describe('solid-delete', function () { it('re-render when label change', () => { cy.get('solid-delete#test1').then(el => { el.attr('data-label', 'Supprimer la ressource'); - cy.get('solid-delete#test1 > button').should('have.text', 'Supprimer la ressource'); - }) + cy.get('solid-delete#test1 > button').should( + 'have.text', + 'Supprimer la ressource', + ); + }); }); -}) - +}); diff --git a/cypress/e2e/e2e/solid-display.cy.ts b/cypress/e2e/e2e/solid-display.cy.ts index 450219e6..7631e04d 100644 --- a/cypress/e2e/e2e/solid-display.cy.ts +++ b/cypress/e2e/e2e/solid-display.cy.ts @@ -1,44 +1,59 @@ -describe('solid-display', function() { +describe('solid-display', function () { this.beforeEach('visit', () => { - cy.visit('/examples/e2e/solid-display.html') + cy.visit('/examples/e2e/solid-display.html'); }); it('display event', () => { - cy.get('#display-1>div').children().eq(0).should('have.attr', 'name', 'event') + cy.get('#display-1>div') + .children() + .eq(0) + .should('have.attr', 'name', 'event') .should('have.attr', 'value', 'Event name and date : ') .should('have.class', 'presentationEvent'); - cy.get('#display-2 solid-set-default').should('have.attr', 'name', 'completeName') + cy.get('#display-2 solid-set-default') + .should('have.attr', 'name', 'completeName') .should('have.class', 'completeName') - .children().should('have.length', 3); + .children() + .should('have.length', 3); }); it('handle fields attribute', () => { // all fields - cy.get('#display-3>div').children().eq(0) - .should('not.have.attr', 'fields'); - cy.get('#display-3>div').children().eq(0) - .find('>div').children() + cy.get('#display-3>div').children().eq(0).should('not.have.attr', 'fields'); + cy.get('#display-3>div') + .children() + .eq(0) + .find('>div') + .children() .should('have.length', 10); - cy.get('#display-3 > div ') - .find("[name=permissions]") - .should('not.exist'); - + cy.get('#display-3 > div ').find('[name=permissions]').should('not.exist'); + // child-[field] attribute - cy.get('#display-3 > div').children().eq(0) + cy.get('#display-3 > div') + .children() + .eq(0) .should('have.attr', 'attribute-child', 'child-value'); - cy.get('#display-3 > div').children().eq(1) + cy.get('#display-3 > div') + .children() + .eq(1) .should('have.attr', 'attribute-child', 'child-value'); - cy.get('#display-3 > div').children().eq(2) + cy.get('#display-3 > div') + .children() + .eq(2) .should('have.attr', 'attribute-chIld', 'child-value'); - cy.get('#display-3 > div').children().eq(3) + cy.get('#display-3 > div') + .children() + .eq(3) .should('have.attr', 'attribute-child', 'child-value'); // no fields - cy.get('#display-4>div').children() - .should('have.attr', 'fields', ''); - cy.get('#display-4>div').children().eq(0) - .find('>div').children() + cy.get('#display-4>div').children().should('have.attr', 'fields', ''); + cy.get('#display-4>div') + .children() + .eq(0) + .find('>div') + .children() .should('have.length', 0); }); @@ -50,34 +65,41 @@ describe('solid-display', function() { }); it('required mixin', () => { - cy.get('#display-6 > div') - .children().should('have.length', 4); + cy.get('#display-6 > div').children().should('have.length', 4); cy.get('#display-7').should('have.attr', 'required-ocean'); - cy.get('#display-7 > div') - .children().should('have.length', 0); + cy.get('#display-7 > div').children().should('have.length', 0); cy.get('#display-8').should('have.attr', 'required-city'); + cy.get('#display-8 > div').children().should('have.length', 2); cy.get('#display-8 > div') - .children().should('have.length', 2) - cy.get('#display-8 > div').children().eq(0) - .should('have.attr', 'data-src', '/examples/data/list/event-3.jsonld'); - cy.get('#display-8 > div').children().eq(1) - .should('have.attr', 'data-src', '/examples/data/list/event-4.jsonld'); + .children() + .eq(0) + .should('have.attr', 'data-src', '/examples/data/list/event-3.jsonld'); + cy.get('#display-8 > div') + .children() + .eq(1) + .should('have.attr', 'data-src', '/examples/data/list/event-4.jsonld'); cy.get('#display-9').should('have.attr', 'required-place'); + cy.get('#display-9 > div').children().should('have.length', 2); + cy.get('#display-9 > div') + .children() + .eq(0) + .should('have.attr', 'data-src', '/examples/data/list/event-2.jsonld'); cy.get('#display-9 > div') - .children().should('have.length', 2); - cy.get('#display-9 > div').children().eq(0) - .should('have.attr', 'data-src', '/examples/data/list/event-2.jsonld'); - cy.get('#display-9 > div').children().eq(1) - .should('have.attr', 'data-src', '/examples/data/list/event-3.jsonld'); + .children() + .eq(1) + .should('have.attr', 'data-src', '/examples/data/list/event-3.jsonld'); cy.get('#display-10').should('have.attr', 'required-city'); cy.get('#display-10').should('have.attr', 'required-place'); - cy.get('#display-10 > div').children().should('have.length', 1) - cy.get('#display-10 > div > solid-display') - .should('have.attr', 'data-src', '/examples/data/list/event-3.jsonld');; + cy.get('#display-10 > div').children().should('have.length', 1); + cy.get('#display-10 > div > solid-display').should( + 'have.attr', + 'data-src', + '/examples/data/list/event-3.jsonld', + ); }); it('list-mixin : solid-container & solid-resource attributes', () => { @@ -85,71 +107,112 @@ describe('solid-display', function() { cy.get('#display-11 > div').children().should('have.length', 4); cy.get('#display-12').should('have.attr', 'solid-resource'); - cy.get('#display-12 > div').children().should('have.length',1); + cy.get('#display-12 > div').children().should('have.length', 1); }); it('list-mixin : empty-value', () => { cy.get('#display-13').find('no-skill'); - cy.get('#display-13 > span > no-skill').contains('No skill yet') + cy.get('#display-13 > span > no-skill').contains('No skill yet'); }); it('define src attribute of solid-link by action', () => { - cy.get('#display-14 > div > solid-action') - .should('have.attr', 'src', '/examples/data/list/user-1.jsonld'); - cy.get('#display-14 > div > solid-action > solid-link') - .should('have.attr', 'data-src', '/examples/data/list/user-1.jsonld'); + cy.get('#display-14 > div > solid-action').should( + 'have.attr', + 'src', + '/examples/data/list/user-1.jsonld', + ); + cy.get('#display-14 > div > solid-action > solid-link').should( + 'have.attr', + 'data-src', + '/examples/data/list/user-1.jsonld', + ); - cy.get('#display-15 > div > solid-action') - .should('have.attr', 'src', 'other-resource'); - cy.get('#display-15 > div > solid-action > solid-link') - .should('have.attr', 'data-src', 'other-resource'); - }); + cy.get('#display-15 > div > solid-action').should( + 'have.attr', + 'src', + 'other-resource', + ); + cy.get('#display-15 > div > solid-action > solid-link').should( + 'have.attr', + 'data-src', + 'other-resource', + ); + }); it('handle default-[field] attribute', () => { - cy.get('#default-field > div solid-display-value') - .should('have.text', 'not defined'); + cy.get('#default-field > div solid-display-value').should( + 'have.text', + 'not defined', + ); }); it('counter mixin', () => { - cy.get('#display-16').children().eq(0) + cy.get('#display-16') + .children() + .eq(0) .should('contain', '8 skills displayed :'); - cy.get('#display-16').children().eq(1) - .find('div').should('have.length', '8'); + cy.get('#display-16') + .children() + .eq(1) + .find('div') + .should('have.length', '8'); }); it('highlighter-mixin', () => { - cy.get('#display-17 > div').children().eq(0) - .find('solid-display-value').should('contain', 'Javascript') + cy.get('#display-17 > div') + .children() + .eq(0) + .find('solid-display-value') + .should('contain', 'Javascript'); }); it('nested-[field]', () => { // data-src in solid-display pointed on skill-*.jsonld - cy.get('#display-18 > div').children().eq(0) + cy.get('#display-18 > div') + .children() + .eq(0) .should('have.attr', 'data-src', '/examples/data/list/skill-2.jsonld'); - cy.get('#display-18 > div').children().eq(1) - .should('have.attr','data-src', '/examples/data/list/skill-3.jsonld'); + cy.get('#display-18 > div') + .children() + .eq(1) + .should('have.attr', 'data-src', '/examples/data/list/skill-3.jsonld'); // User's name not displayed - cy.get('#display-18 > div').children().eq(0) - .find('solid-display-value').should('not.contain.value', 'Test User'); - cy.get('#display-18 > div').children().eq(1) - .find('solid-display-value').should('not.contain.value', 'Test User'); + cy.get('#display-18 > div') + .children() + .eq(0) + .find('solid-display-value') + .should('not.contain.value', 'Test User'); + cy.get('#display-18 > div') + .children() + .eq(1) + .find('solid-display-value') + .should('not.contain.value', 'Test User'); // Skills' name displayed - cy.get('#display-18 > div').children().eq(0) - .find('solid-display-value').should('have.attr', 'value', 'CSS'); - cy.get('#display-18 > div').children().eq(1) - .find('solid-display-value').should('have.attr','value', 'Javascript'); + cy.get('#display-18 > div') + .children() + .eq(0) + .find('solid-display-value') + .should('have.attr', 'value', 'CSS'); + cy.get('#display-18 > div') + .children() + .eq(1) + .find('solid-display-value') + .should('have.attr', 'value', 'Javascript'); }); it('default-widget', () => { // default-widget applied to every child cy.get('#display-19 > div') - .find('solid-display-link').eq(0) + .find('solid-display-link') + .eq(0) .should('have.attr', 'name', 'name'); cy.get('#display-19 > div') - .find('solid-display-link').eq(1) + .find('solid-display-link') + .eq(1) .should('have.attr', 'name', 'email'); cy.get('#display-19 > div') - .find('solid-display-link').eq(2) + .find('solid-display-link') + .eq(2) .should('have.attr', 'name', 'username'); // default-widget applied to several children @@ -157,32 +220,44 @@ describe('solid-display', function() { .find('solid-display-div') .should('have.attr', 'name', 'name'); cy.get('#display-20 > div') - .find('solid-display-link').eq(0) + .find('solid-display-link') + .eq(0) .should('have.attr', 'name', 'email'); cy.get('#display-20 > div') - .find('solid-display-link').eq(1) + .find('solid-display-link') + .eq(1) .should('have.attr', 'name', 'username'); }); it('oembed template', () => { cy.get('#display-21 > div') .find('solid-display-value-oembed') - .should('have.attr', 'value', 'https://www.audiomack.com/oembed?url=https%3A%2F%2Faudiomack.com%2Faudiomack%2Fplaylist%2Fjust-chillin&format=json'); + .should( + 'have.attr', + 'value', + 'https://www.audiomack.com/oembed?url=https%3A%2F%2Faudiomack.com%2Faudiomack%2Fplaylist%2Fjust-chillin&format=json', + ); }); it('default-widget-[field]', () => { + cy.get('#display-22 > div').children().should('have.length', 4); + cy.get('#display-22 > div').children().eq(1).should('contain', 'Rennes'); + cy.get('#display-22 > div > custom-default-widget').should( + 'contain', + 'Field empty', + ); cy.get('#display-22 > div') - .children().should('have.length', 4); - cy.get('#display-22 > div').children().eq(1) - .should('contain', 'Rennes'); - cy.get('#display-22 > div > custom-default-widget') - .should('contain', 'Field empty'); - cy.get('#display-22 > div').children().eq(0) + .children() + .eq(0) .should('contain', 'Field empty'); - cy.get('#display-22 > div').children().eq(2) + cy.get('#display-22 > div') + .children() + .eq(2) .should('contain', 'Field empty'); - cy.get('#display-22 > div > custom-default-widget-website') - .should('contain', 'No website'); + cy.get('#display-22 > div > custom-default-widget-website').should( + 'contain', + 'No website', + ); }); it('dispatch event when widget rendered', () => { @@ -191,46 +266,68 @@ describe('solid-display', function() { it('widget for empty set', () => { // empty set widget displayed + cy.get('#widget-empty-set1 > div').children().should('have.length', 2); cy.get('#widget-empty-set1 > div') - .children().should('have.length', 2); - cy.get('#widget-empty-set1 > div') - .children().eq(1).children() + .children() + .eq(1) + .children() .should('have.length', 1); cy.get('#widget-empty-set1 > div') - .children().eq(1) + .children() + .eq(1) .should('contain', 'set empty'); // empty set widget not displayed + cy.get('#widget-empty-set2 > div').children().should('have.length', 2); cy.get('#widget-empty-set2 > div') - .children().should('have.length', 2); - cy.get('#widget-empty-set2 > div') - .children().eq(1).children() + .children() + .eq(1) + .children() .should('have.length', 3); cy.get('#widget-empty-set2 > div') - .children().eq(1).should('contain', 'Paris') + .children() + .eq(1) + .should('contain', 'Paris') .and('not.contain', 'set empty'); // empty set with value attribute displayed + cy.get('#widget-empty-set3 > div').children().should('have.length', 2); cy.get('#widget-empty-set3 > div') - .children().should('have.length', 2); - cy.get('#widget-empty-set3 > div') - .children().eq(1) + .children() + .eq(1) .should('have.attr', 'value', 'empty set value'); cy.get('#widget-empty-set3 > div') - .children().eq(1).should('contain', 'empty set value') + .children() + .eq(1) + .should('contain', 'empty set value') .and('not.contain', 'set empty'); }); - it('solid-set-div-label', () => { + it('solid-set-div-label', () => { + cy.get('#solid-set-div-label > div').children().should('have.length', 4); + cy.get('#solid-set-div-label > div') + .children() + .eq(0) + .find('solid-set-div-label') + .children() + .should('have.length', 2); + cy.get( + '#solid-set-div-label > div > solid-display > div > solid-set-div-label', + ) + .find('label') + .should('contain', 'identity'); cy.get('#solid-set-div-label > div') - .children().should('have.length', 4); - cy.get('#solid-set-div-label > div').children().eq(0) - .find('solid-set-div-label').children().should('have.length', 2); - cy.get('#solid-set-div-label > div > solid-display > div > solid-set-div-label') - .find('label').should('contain', 'identity'); - cy.get('#solid-set-div-label > div').children().eq(1) - .find('label').should('contain', 'identity'); - cy.get('#solid-set-div-label > div').children().eq(2) - .find('label').should('contain', 'identity'); - cy.get('#solid-set-div-label > div').children().eq(3) - .find('label').should('contain', 'identity'); - }) -}) \ No newline at end of file + .children() + .eq(1) + .find('label') + .should('contain', 'identity'); + cy.get('#solid-set-div-label > div') + .children() + .eq(2) + .find('label') + .should('contain', 'identity'); + cy.get('#solid-set-div-label > div') + .children() + .eq(3) + .find('label') + .should('contain', 'identity'); + }); +}); diff --git a/cypress/e2e/e2e/solid-form-file.cy.ts b/cypress/e2e/e2e/solid-form-file.cy.ts index 2cabf4f4..5ed36ff8 100644 --- a/cypress/e2e/e2e/solid-form-file.cy.ts +++ b/cypress/e2e/e2e/solid-form-file.cy.ts @@ -1,62 +1,97 @@ // TODO: We should make tests run independently of one another -describe('solid-form-file test', { testIsolation: false }, function() { +describe('solid-form-file test', { testIsolation: false }, function () { this.beforeAll('visit', () => { - cy.visit('/examples/e2e/solid-form-file.html') + cy.visit('/examples/e2e/solid-form-file.html'); }); - it('upload file with solid-form-file', function() { - cy.get('#form-file [name=picture] input[type=file]').uploadFile('../../fake-image.svg') + it('upload file with solid-form-file', function () { + cy.get('#form-file [name=picture] input[type=file]').uploadFile( + '../../fake-image.svg', + ); cy.get('#form-file input[name=picture]').should($i => { - expect($i.val()).to.match(/\/upload\/[0-9a-f]+.jpg$/) - }) - }) + expect($i.val()).to.match(/\/upload\/[0-9a-f]+.jpg$/); + }); + }); - it('upload image with solid-form-file-image', function() { - cy.get('#form-image solid-form-image input[type=file]').uploadFile('../../fake-image.svg') + it('upload image with solid-form-file-image', function () { + cy.get('#form-image solid-form-image input[type=file]').uploadFile( + '../../fake-image.svg', + ); cy.get('#form-image solid-form-image img').should($i => { - expect($i.attr('src')).to.not.match(/\/upload\/fruits.jpg$/) - expect($i.attr('src')).to.match(/\/upload\/[0-9a-f]+.jpg$/) - }) - }) - - it('resets the file', function() { - cy.get('#reset-file solid-form-file input[type=file]').uploadFile('../../fake-image.svg') + expect($i.attr('src')).to.not.match(/\/upload\/fruits.jpg$/); + expect($i.attr('src')).to.match(/\/upload\/[0-9a-f]+.jpg$/); + }); + }); + + it('resets the file', function () { + cy.get('#reset-file solid-form-file input[type=file]').uploadFile( + '../../fake-image.svg', + ); cy.get('#reset-file solid-form-file input[name=picture]').should($i => { - expect($i.val()).to.match(/\/upload\/[0-9a-f]+.jpg$/) - }) + expect($i.val()).to.match(/\/upload\/[0-9a-f]+.jpg$/); + }); cy.wait(500); cy.get('#reset-file input[type=reset]').click(); cy.get('#reset-file solid-form-file input[type=file]').should('be.empty'); - cy.get('#reset-file solid-form-file input[type=text]').should('have.value', '../../upload/fruits.jpg'); + cy.get('#reset-file solid-form-file input[type=text]').should( + 'have.value', + '../../upload/fruits.jpg', + ); cy.get('#reset-file solid-form-file button').should('have.attr', 'hidden'); - }) + }); it('resets the image', function () { - cy.get('#reset-image solid-form-image input[type=file]').uploadFile('../../fake-image.svg') + cy.get('#reset-image solid-form-image input[type=file]').uploadFile( + '../../fake-image.svg', + ); cy.get('#reset-image solid-form-image img').should($i => { - expect($i.attr('src')).to.not.match(/\/upload\/fruits.jpg$/) - expect($i.attr('src')).to.match(/\/upload\/[0-9a-f]+.jpg$/) - }) + expect($i.attr('src')).to.not.match(/\/upload\/fruits.jpg$/); + expect($i.attr('src')).to.match(/\/upload\/[0-9a-f]+.jpg$/); + }); cy.get('#reset-image input[type=reset]').click(); cy.get('#reset-image solid-form-image img').should($i => { - expect($i.attr('src')).to.match(/\/upload\/fruits.jpg$/) - }) + expect($i.attr('src')).to.match(/\/upload\/fruits.jpg$/); + }); cy.get('#reset-image solid-form-image input[type=file]').should('be.empty'); - cy.get('#reset-image solid-form-image input[type=text]').should('have.value', '../../upload/fruits.jpg'); - cy.get('#reset-image solid-form-image button').should('have.attr', 'hidden'); + cy.get('#reset-image solid-form-image input[type=text]').should( + 'have.value', + '../../upload/fruits.jpg', + ); + cy.get('#reset-image solid-form-image button').should( + 'have.attr', + 'hidden', + ); }); - it('handles required', function() { - cy.get('#form-required-image solid-form-image input[type=text]').should('have.attr', 'required') - cy.get('#form-required-image solid-form-image input[type=file]').should('not.have.attr', 'required') - cy.get('#form-required-file solid-form-file input[type=text]').should('have.attr', 'required') - cy.get('#form-required-file solid-form-file input[type=file]').should('not.have.attr', 'required') - }) + it('handles required', function () { + cy.get('#form-required-image solid-form-image input[type=text]').should( + 'have.attr', + 'required', + ); + cy.get('#form-required-image solid-form-image input[type=file]').should( + 'not.have.attr', + 'required', + ); + cy.get('#form-required-file solid-form-file input[type=text]').should( + 'have.attr', + 'required', + ); + cy.get('#form-required-file solid-form-file input[type=file]').should( + 'not.have.attr', + 'required', + ); + }); - it('displays file name if source not empty', function() { + it('displays file name if source not empty', function () { cy.visit('/examples/e2e/solid-form-file.html'); // if not then page is not updated, and another file is uploaded from the prev test - cy.get('#form-file solid-form-file[name=picture] a[href="../../upload/fruits.jpg"]').contains("fruits.jpg") - cy.get('#reset-file solid-form-file[name=picture] a[href="../../upload/fruits.jpg"]').contains("fruits.jpg") - cy.get('#form-required-file solid-form-file[name=picture] a[href="../../upload/fruits.jpg"]').contains("fruits.jpg") - }) -}) \ No newline at end of file + cy.get( + '#form-file solid-form-file[name=picture] a[href="../../upload/fruits.jpg"]', + ).contains('fruits.jpg'); + cy.get( + '#reset-file solid-form-file[name=picture] a[href="../../upload/fruits.jpg"]', + ).contains('fruits.jpg'); + cy.get( + '#form-required-file solid-form-file[name=picture] a[href="../../upload/fruits.jpg"]', + ).contains('fruits.jpg'); + }); +}); diff --git a/cypress/e2e/e2e/solid-form-richtext.cy.ts b/cypress/e2e/e2e/solid-form-richtext.cy.ts index 430b07f0..1e6b2b45 100644 --- a/cypress/e2e/e2e/solid-form-richtext.cy.ts +++ b/cypress/e2e/e2e/solid-form-richtext.cy.ts @@ -1,86 +1,109 @@ describe('solid-form-richtext test', function () { - this.beforeEach('visit', () => { - cy.visit('/examples/e2e/solid-form-richtext.html'); - }); + this.beforeEach('visit', () => { + cy.visit('/examples/e2e/solid-form-richtext.html'); + }); - it('Submitting form with filled rich text input should not display an error', () => { - cy.get('solid-form div[data-richtext] p').should('not.have.length', 0); - cy.get('#form-1 input[type="submit"]').click(); - cy.get('#form-1 div[data-richtext] .required-error-message').should('not.exist'); - cy.get('#form-1 div[data-richtext] .error-border-richtext').should('not.exist'); - }); + it('Submitting form with filled rich text input should not display an error', () => { + cy.get('solid-form div[data-richtext] p').should('not.have.length', 0); + cy.get('#form-1 input[type="submit"]').click(); + cy.get('#form-1 div[data-richtext] .required-error-message').should( + 'not.exist', + ); + cy.get('#form-1 div[data-richtext] .error-border-richtext').should( + 'not.exist', + ); + }); - it('Submitting form with empty rich text input should display an error mesage', () => { - cy.get('#form-1 div[data-richtext] p').clear(); - cy.get('#form-1 input[type="submit"]').click(); - cy.get('#form-1 div[data-richtext] .required-error-message').should('exist'); - cy.get('#form-1 div[data-richtext].error-border-richtext').should('exist'); - }); - - it('Error message disappears when retyping in rich text input', () => { - // Empty fields , error is shown - cy.get('#form-1 div[data-richtext] p').clear(); - cy.get('#form-1 input[type="submit"]').click(); - cy.get('#form-1 div[data-richtext] .required-error-message').should('exist'); - cy.get('#form-1 div[data-richtext].error-border-richtext').should('exist'); + it('Submitting form with empty rich text input should display an error mesage', () => { + cy.get('#form-1 div[data-richtext] p').clear(); + cy.get('#form-1 input[type="submit"]').click(); + cy.get('#form-1 div[data-richtext] .required-error-message').should( + 'exist', + ); + cy.get('#form-1 div[data-richtext].error-border-richtext').should('exist'); + }); - // Retype text , error disapears - cy.get('#form-1 div[data-richtext] p').type('some text'); - cy.get('#form-1 input[type="submit"]').click(); - cy.get('#form-1 div[data-richtext] .required-error-message').should('not.exist'); - cy.get('#form-1 div[data-richtext] .error-border-richtext').should('not.exist'); - }); + it('Error message disappears when retyping in rich text input', () => { + // Empty fields , error is shown + cy.get('#form-1 div[data-richtext] p').clear(); + cy.get('#form-1 input[type="submit"]').click(); + cy.get('#form-1 div[data-richtext] .required-error-message').should( + 'exist', + ); + cy.get('#form-1 div[data-richtext].error-border-richtext').should('exist'); - it('Placeholder is displayed text value is empty if placeholder is assigned', () => { - cy.get('#form-1 div[data-richtext] p').clear(); - cy.get('#form-1 div[data-richtext] div[data-placeholder]').should('exist') - cy.get('#form-1 div[data-richtext] div[data-placeholder]').should('have.attr', 'data-placeholder', 'some placeholder') - }); + // Retype text , error disapears + cy.get('#form-1 div[data-richtext] p').type('some text'); + cy.get('#form-1 input[type="submit"]').click(); + cy.get('#form-1 div[data-richtext] .required-error-message').should( + 'not.exist', + ); + cy.get('#form-1 div[data-richtext] .error-border-richtext').should( + 'not.exist', + ); + }); - it('richtext html rendering', () => { - cy.get('#form-2 solid-form-richtext') - .children().should('have.have.length', 2) - .find('button') - .and('have.attr', 'class', 'ql-bold'); - cy.get('#form-2 solid-form-richtext').then($el => { - expect((<any>$el[0]).component.getValue()).to.equal('**Jean-Bernard**\n'); - cy.get('#form-2 solid-form-richtext .ql-editor').type('{selectall}Jean-Claude{selectall}') - cy.get('#form-2 solid-form-richtext .ql-italic') - .click() - cy.get('#form-2 solid-form-richtext .ql-bold') - .click() - cy.get('#form-2 solid-form-richtext .ql-editor') - .find('em') - .should('have.text', 'Jean-Claude') - cy.get('#form-2 solid-form-richtext').then($el => { - expect((<any>$el[0]).component.getValue()).to.equal('_Jean-Claude_\n') - }); - }); - // add link button in richtext mixin - cy.get('#form-3 solid-form-richtext > div ').children().eq(4) - .find('button') - .and('have.attr', 'class', 'ql-link'); - cy.get('#form-3 solid-form-richtext .ql-editor').type('{selectall}test link{selectall}') - cy.get('#form-3 solid-form-richtext .ql-link') - .click() - cy.get('#form-3 solid-form-richtext > div[name=name] > div[data-mode=link] > input[type=text]') - .type('http://www.yesnoif.com/') - cy.get('#form-3 solid-form-richtext > div[name=name] > div[data-mode=link] > a[class=ql-action]') - .click() - cy.get('#form-3 solid-form-richtext .ql-editor') - .find('a').should('have.attr', 'href', 'http://www.yesnoif.com/') - .and('contain', 'test link'); - // verify value format sent in the form - cy.get('#form-3 input[type=submit]').click() - cy.get('#form-3').then($el => { - return (<any>$el[0]).component.getFormValue().then(res => { - expect(res.name).to.equal('[test link](http://www.yesnoif.com/)\n'); - }); - }); - // value stocked in markdown well displayed in the solid-form-richtext - cy.get('#form-4 solid-form-richtext > div[name=website]') - .find('a').should('have.attr', 'href', 'http://drawing.garden/') - .and('contain', 'my site') - }); + it('Placeholder is displayed text value is empty if placeholder is assigned', () => { + cy.get('#form-1 div[data-richtext] p').clear(); + cy.get('#form-1 div[data-richtext] div[data-placeholder]').should('exist'); + cy.get('#form-1 div[data-richtext] div[data-placeholder]').should( + 'have.attr', + 'data-placeholder', + 'some placeholder', + ); + }); -}) \ No newline at end of file + it('richtext html rendering', () => { + cy.get('#form-2 solid-form-richtext') + .children() + .should('have.have.length', 2) + .find('button') + .and('have.attr', 'class', 'ql-bold'); + cy.get('#form-2 solid-form-richtext').then($el => { + expect((<any>$el[0]).component.getValue()).to.equal('**Jean-Bernard**\n'); + cy.get('#form-2 solid-form-richtext .ql-editor').type( + '{selectall}Jean-Claude{selectall}', + ); + cy.get('#form-2 solid-form-richtext .ql-italic').click(); + cy.get('#form-2 solid-form-richtext .ql-bold').click(); + cy.get('#form-2 solid-form-richtext .ql-editor') + .find('em') + .should('have.text', 'Jean-Claude'); + cy.get('#form-2 solid-form-richtext').then($el => { + expect((<any>$el[0]).component.getValue()).to.equal('_Jean-Claude_\n'); + }); + }); + // add link button in richtext mixin + cy.get('#form-3 solid-form-richtext > div ') + .children() + .eq(4) + .find('button') + .and('have.attr', 'class', 'ql-link'); + cy.get('#form-3 solid-form-richtext .ql-editor').type( + '{selectall}test link{selectall}', + ); + cy.get('#form-3 solid-form-richtext .ql-link').click(); + cy.get( + '#form-3 solid-form-richtext > div[name=name] > div[data-mode=link] > input[type=text]', + ).type('http://www.yesnoif.com/'); + cy.get( + '#form-3 solid-form-richtext > div[name=name] > div[data-mode=link] > a[class=ql-action]', + ).click(); + cy.get('#form-3 solid-form-richtext .ql-editor') + .find('a') + .should('have.attr', 'href', 'http://www.yesnoif.com/') + .and('contain', 'test link'); + // verify value format sent in the form + cy.get('#form-3 input[type=submit]').click(); + cy.get('#form-3').then($el => { + return (<any>$el[0]).component.getFormValue().then(res => { + expect(res.name).to.equal('[test link](http://www.yesnoif.com/)\n'); + }); + }); + // value stocked in markdown well displayed in the solid-form-richtext + cy.get('#form-4 solid-form-richtext > div[name=website]') + .find('a') + .should('have.attr', 'href', 'http://drawing.garden/') + .and('contain', 'my site'); + }); +}); diff --git a/cypress/e2e/e2e/solid-form.cy.ts b/cypress/e2e/e2e/solid-form.cy.ts index a9b8b1a2..aa3192e9 100644 --- a/cypress/e2e/e2e/solid-form.cy.ts +++ b/cypress/e2e/e2e/solid-form.cy.ts @@ -1,18 +1,20 @@ // TODO: We should make tests run independently of one another -describe('solid-form', { testIsolation: false }, function() { +describe('solid-form', { testIsolation: false }, function () { let win: Window; this.beforeAll('visit', () => { cy.visit('/examples/e2e/solid-form.html'); cy.window().then(w => { win = w; }); - }); it('creation form', () => { - cy.get('#form-1 input[type=text]').should('have.length', 2) + cy.get('#form-1 input[type=text]').should('have.length', 2); cy.get('#form-1 input[type=text][name=name]').should('have.value', ''); - cy.get('#form-1 input[type=text][name="contact.email"]').should('have.value', ''); + cy.get('#form-1 input[type=text][name="contact.email"]').should( + 'have.value', + '', + ); cy.get('#form-1').then($el => { return (<any>$el[0]).component.getFormValue().then(res => { expect(res).to.deep.equal({ name: '', contact: { email: '' } }); @@ -21,7 +23,7 @@ describe('solid-form', { testIsolation: false }, function() { }); it('edition form', () => { - cy.get('#form-edition-1 input[type=text]').should('have.length', 2) + cy.get('#form-edition-1 input[type=text]').should('have.length', 2); cy.get('#form-edition-1 input[type=text][name=name]') .should('have.value', 'Coliving') .type(' in BZH'); @@ -32,55 +34,58 @@ describe('solid-form', { testIsolation: false }, function() { cy.get('#form-edition-1').then($el => { return (<any>$el[0]).component.getFormValue().then(res => { expect(res).to.deep.equal({ - "@id": "/examples/data/list/event-1.jsonld", + '@id': '/examples/data/list/event-1.jsonld', contact: { email: 'admin@example.com', - "@id": "/examples/data/list/user-1.jsonld", + '@id': '/examples/data/list/user-1.jsonld', }, name: 'Coliving in BZH', }); }); }); - cy.intercept("PUT", '**/event-1.jsonld', { + cy.intercept('PUT', '**/event-1.jsonld', { headers: { - contentType: 'application/ld+json' - } - }) + contentType: 'application/ld+json', + }, + }); - cy.get('#form-edition-2 input[type=text][name=name]') - .type(' in BZH'); - cy.get('#form-edition-2 select').select('Pierre DLC') + cy.get('#form-edition-2 input[type=text][name=name]').type(' in BZH'); + cy.get('#form-edition-2 select').select('Pierre DLC'); cy.get('#form-edition-2').then($el => { return (<any>$el[0]).component.getFormValue().then(res => { expect(res).to.deep.equal({ name: 'Coliving in BZH', contact: { - "@id": "/examples/data/list/user-4.jsonld", + '@id': '/examples/data/list/user-4.jsonld', }, - "@id": "/examples/data/list/event-1.jsonld", + '@id': '/examples/data/list/event-1.jsonld', }); }); }); cy.get('#form-edition-2 input[type="submit"]').click(); // After submit, form is re-rendered properly - cy.get('#form-edition-2 input[type=text][name=name]') - .should('have.value', 'Coliving'); - cy.get('#form-edition-2 select') - .should('have.value', '{"@id": "/examples/data/list/user-1.jsonld"}'); + cy.get('#form-edition-2 input[type=text][name=name]').should( + 'have.value', + 'Coliving', + ); + cy.get('#form-edition-2 select').should( + 'have.value', + '{"@id": "/examples/data/list/user-1.jsonld"}', + ); // Nested container cy.get('#form-edition-3').then($el => { return (<any>$el[0]).component.getFormValue().then(res => { expect(res).to.deep.equal({ skills: { - "ldp:contains": [ - { "@id": "/examples/data/list/skill-2.jsonld" }, - { "@id": "/examples/data/list/skill-3.jsonld" }, + 'ldp:contains': [ + { '@id': '/examples/data/list/skill-2.jsonld' }, + { '@id': '/examples/data/list/skill-3.jsonld' }, ], - "@id": "/examples/data/list/user-1-skills.jsonld", + '@id': '/examples/data/list/user-1-skills.jsonld', }, - "@id": "/examples/data/list/user-1.jsonld" + '@id': '/examples/data/list/user-1.jsonld', }); }); }); @@ -91,17 +96,17 @@ describe('solid-form', { testIsolation: false }, function() { .should('have.attr', 'range', '/examples/data/list/skills.jsonld') .should('have.attr', 'data-src', '/examples/data/list/skills.jsonld') .should('have.attr', 'order-desc', 'name') - .should('have.attr', 'name', 'skills') + .should('have.attr', 'name', 'skills'); cy.get('#form-3 solid-form-label-placeholder-text') .should('have.attr', 'label', 'Test label') .should('have.attr', 'placeholder', 'test placeholder') .should('have.attr', 'class', 'test-class') - .should('have.attr', 'required') + .should('have.attr', 'required'); cy.get('#form-3 solid-form-label-placeholder-text') .find('input') - .should('have.attr', 'placeholder', 'test placeholder') + .should('have.attr', 'placeholder', 'test placeholder'); }); it('solid-form + pattern, title attributes', () => { @@ -119,94 +124,90 @@ describe('solid-form', { testIsolation: false }, function() { .find('input[type=submit]') .should('have.value', 'Register'); - cy.get('solid-form#form-6') - .then(el => { - el.attr('submit-button', 'Register the user'); - cy.get('solid-form#form-6') + cy.get('solid-form#form-6').then(el => { + el.attr('submit-button', 'Register the user'); + cy.get('solid-form#form-6') .find('input[type=submit]') .should('have.value', 'Register the user'); - }) - cy.get('solid-form-search#form-search-6') - .then(el => { - el.attr('submit-button', 'Register the user'); - cy.get('solid-form-search#form-search-6') + }); + cy.get('solid-form-search#form-search-6').then(el => { + el.attr('submit-button', 'Register the user'); + cy.get('solid-form-search#form-search-6') .find('input[type=submit]') .should('have.value', 'Register the user'); - }) + }); }); it('show errors without resetting', () => { cy.intercept('POST', '**/events.jsonld', { statusCode: 400, - body: { - "name": - [ - "Ensure this field has no more than 10 characters." - ], - "batches": { - "title": ["Title too long", "Title not unique"], - "tasks": { - "@id": ["Task with this urlid already exists."], - "amount": ["Should be > 0"] - } + body: { + name: ['Ensure this field has no more than 10 characters.'], + batches: { + title: ['Title too long', 'Title not unique'], + tasks: { + '@id': ['Task with this urlid already exists.'], + amount: ['Should be > 0'], + }, }, - "@context": "https://cdn.startinblox.com/owl/context.jsonld" + '@context': 'https://cdn.startinblox.com/owl/context.jsonld', }, headers: { - 'content-type': 'application/ld+json' - } - }) + 'content-type': 'application/ld+json', + }, + }); cy.get('solid-form#form-7') .find('input[name=name]') .type('Mon très long titre'); - cy.get('solid-form#form-7') - .find('input[type=submit]') - .click(); + cy.get('solid-form#form-7').find('input[type=submit]').click(); cy.get('solid-form#form-7') .find('[data-id="error"]') .should('contain', 'A validation error occurred.') .and('not.contain', '@context'); cy.get('solid-form#form-7') .find('input[name=name]') - .should('have.value', 'Mon très long titre') + .should('have.value', 'Mon très long titre'); cy.get('solid-form#form-7') .find('.error[name=name] .error-message') - .should('contain', 'Ensure this field has no more than 10 characters.') + .should('contain', 'Ensure this field has no more than 10 characters.'); cy.get('solid-form#form-7') .find('.error[name="batches.title"] .error-message') - .should('contain', 'Title too long') + .should('contain', 'Title too long'); cy.get('solid-form#form-7') .find('.error[name="batches.tasks"] .error-message') - .should('contain', 'Task with this urlid already exists.') + .should('contain', 'Task with this urlid already exists.'); cy.get('solid-form#form-7') .find('.error[name="batches.tasks"] .error-message') - .should('contain', 'Should be > 0') + .should('contain', 'Should be > 0'); // removes error after new submission - cy.intercept("POST", '**/events.jsonld', { + cy.intercept('POST', '**/events.jsonld', { headers: { - contentType: 'application/ld+json' + contentType: 'application/ld+json', }, - body: 'ok' - }) + body: 'ok', + }); - cy.get('solid-form#form-7') - .find('input[type=submit]') - .click(); - cy.get('solid-form#form-7') - .find('[data-id="error"]').should('be.empty') + cy.get('solid-form#form-7').find('input[type=submit]').click(); + cy.get('solid-form#form-7').find('[data-id="error"]').should('be.empty'); }); it('partial attribute', () => { cy.spy(win.sibStore, 'put'); - cy.get('#form-8').find('input[type=submit]').click().then(() => { - expect(win.sibStore.put).to.be.called; - }); + cy.get('#form-8') + .find('input[type=submit]') + .click() + .then(() => { + expect(win.sibStore.put).to.be.called; + }); cy.spy(win.sibStore, 'patch'); - cy.get('#form-9').find('input[type=submit]').click().then(() => { - expect(win.sibStore.patch).to.be.called; - }); + cy.get('#form-9') + .find('input[type=submit]') + .click() + .then(() => { + expect(win.sibStore.patch).to.be.called; + }); }); it('naked attribute', () => { @@ -215,129 +216,155 @@ describe('solid-form', { testIsolation: false }, function() { it('loader-id attribute', () => { cy.get('#form-loader').should('have.attr', 'hidden'); - cy.intercept("POST", '**/users.jsonld', { - delay: 3000 - }) - - cy.get('#form-11') - .find('input[name=name]') - .type('Tryphon'); - cy.get('#form-11') - .find('input[type=submit]') - .click(); + cy.intercept('POST', '**/users.jsonld', { + delay: 3000, + }); + + cy.get('#form-11').find('input[name=name]').type('Tryphon'); + cy.get('#form-11').find('input[type=submit]').click(); cy.get('#form-loader').should('not.have.attr', 'hidden'); }); it('solid-form with addable attributes', () => { // Verify addable's attributes are passed in the solid-form-dropdown-addable cy.get('solid-form#form-addable > form > solid-form-dropdown-addable') - .should('have.attr', 'name', 'skills') - .and('have.attr', 'addable-data-src', '/examples/data/list/users.jsonld') - .and('have.attr', 'addable-fields', 'name') - .and('have.attr', 'addable-widget-name', 'solid-form-text-placeholder-label') - .and('have.attr', 'addable-placeholder-name', 'Enter skill name') - .and('have.attr', 'addable-submit-button', 'Send name') + .should('have.attr', 'name', 'skills') + .and('have.attr', 'addable-data-src', '/examples/data/list/users.jsonld') + .and('have.attr', 'addable-fields', 'name') + .and( + 'have.attr', + 'addable-widget-name', + 'solid-form-text-placeholder-label', + ) + .and('have.attr', 'addable-placeholder-name', 'Enter skill name') + .and('have.attr', 'addable-submit-button', 'Send name'); }); it('autocomplete attribute', () => { - cy.get('solid-form#form-12 > form > solid-form-label-text').eq(0) - .should('have.attr', 'autocomplete', 'off') - cy.get('solid-form#form-12 > form > solid-form-label-text').eq(0) + cy.get('solid-form#form-12 > form > solid-form-label-text') + .eq(0) + .should('have.attr', 'autocomplete', 'off'); + cy.get('solid-form#form-12 > form > solid-form-label-text') + .eq(0) .find('input[type=text]') - .should('have.attr', 'autocomplete', 'off') - cy.get('solid-form#form-12 > form > solid-form-label-text').eq(1) - .should('not.have.attr', 'autocomplete') + .should('have.attr', 'autocomplete', 'off'); + cy.get('solid-form#form-12 > form > solid-form-label-text') + .eq(1) + .should('not.have.attr', 'autocomplete'); }); it('autosaves form', () => { cy.spy(win.sibStore, 'patch'); - cy.get('solid-form#form-autosave').find('input[type="submit"]') + cy.get('solid-form#form-autosave') + .find('input[type="submit"]') .should('not.exist'); - cy.get('solid-form#form-autosave input[name="username"]').type('a').then(() => { - expect(win.sibStore.patch).to.have.callCount(0); - }); - cy.get('solid-form#form-autosave input[name="username"]').blur().then(() => { - cy.wait(200).then(() => { - expect(win.sibStore.patch).to.have.callCount(1); + cy.get('solid-form#form-autosave input[name="username"]') + .type('a') + .then(() => { + expect(win.sibStore.patch).to.have.callCount(0); + }); + cy.get('solid-form#form-autosave input[name="username"]') + .blur() + .then(() => { + cy.wait(200).then(() => { + expect(win.sibStore.patch).to.have.callCount(1); + }); + }); + cy.get('solid-form#form-autosave [data-index="skills0"] button') + .click() + .then(() => { + expect(win.sibStore.patch).to.have.callCount(2); }); - }); - cy.get('solid-form#form-autosave [data-index="skills0"] button').click().then(() => { - expect(win.sibStore.patch).to.have.callCount(2); - }); cy.get('solid-form#form-autosave [data-index="skills1"] select') - .select("PHP") - .then(() => { - cy.wait(200).then(() => { - expect(win.sibStore.patch).to.have.callCount(3); - }) - }); + .select('PHP') + .then(() => { + cy.wait(200).then(() => { + expect(win.sibStore.patch).to.have.callCount(3); + }); + }); // Without autosave, no requests - cy.get('solid-form#form-autosave').then(($el) => { + cy.get('solid-form#form-autosave').then($el => { $el.removeAttr('autosave'); - cy.get('solid-form#form-autosave input[name="username"]').type('a').blur().then(() => { - expect(win.sibStore.patch).to.have.callCount(3); - }); + cy.get('solid-form#form-autosave input[name="username"]') + .type('a') + .blur() + .then(() => { + expect(win.sibStore.patch).to.have.callCount(3); + }); }); }); it('submit-widget attribute', () => { - cy.get('solid-form#form-submit-widget').find('input[type="submit"]') + cy.get('solid-form#form-submit-widget') + .find('input[type="submit"]') .should('not.exist'); - cy.get('solid-form#form-submit-widget').find('div').children('button[type="submit"]') + cy.get('solid-form#form-submit-widget') + .find('div') + .children('button[type="submit"]') .should('exist') .and('have.text', 'OK'); }); it('solid-form-time widget with attributes', () => { cy.spy(win.sibStore, 'post'); - cy.get('solid-form#time-widget').find('input[name="name"]') - .type('webinar'); + cy.get('solid-form#time-widget').find('input[name="name"]').type('webinar'); // Check min attribute consideration - cy.get('solid-form#time-widget').find('input[type="time"]') - .type('11:00'); - cy.get('solid-form#time-widget').find('input[type="submit"]') - .click().then(() => { + cy.get('solid-form#time-widget').find('input[type="time"]').type('11:00'); + cy.get('solid-form#time-widget') + .find('input[type="submit"]') + .click() + .then(() => { expect(win.sibStore.post).not.be.called; }); // Check max attribute consideration - cy.get('solid-form#time-widget').find('input[type="time"]') - .type('16:00'); - cy.get('solid-form#time-widget').find('input[type="submit"]') - .click().then(() => { + cy.get('solid-form#time-widget').find('input[type="time"]').type('16:00'); + cy.get('solid-form#time-widget') + .find('input[type="submit"]') + .click() + .then(() => { expect(win.sibStore.post).not.be.called; }); // Check step attribute consideration - cy.get('solid-form#time-widget').find('input[type="time"]') - .type('13:10'); - cy.get('solid-form#time-widget').find('input[type="submit"]') - .click().then(() => { + cy.get('solid-form#time-widget').find('input[type="time"]').type('13:10'); + cy.get('solid-form#time-widget') + .find('input[type="submit"]') + .click() + .then(() => { expect(win.sibStore.post).not.be.called; }); - cy.get('solid-form#time-widget').find('input[type="time"]') - .type('13:00'); - cy.get('solid-form#time-widget').find('input[type="submit"]') - .click().then(() => { + cy.get('solid-form#time-widget').find('input[type="time"]').type('13:00'); + cy.get('solid-form#time-widget') + .find('input[type="submit"]') + .click() + .then(() => { expect(win.sibStore.post).to.be.called; }); }); it('minlength attribute', () => { cy.spy(win.sibStore, 'post'); - cy.get('solid-form#minlength').find('input[type="text"]') + cy.get('solid-form#minlength') + .find('input[type="text"]') .type('{selectall}Sacha'); - cy.get('solid-form#minlength').find('input[type="submit"]').click() + cy.get('solid-form#minlength') + .find('input[type="submit"]') + .click() .then(() => { expect(win.sibStore.post).not.be.called; }); }); it('class-submit-button attribute', () => { - cy.get('solid-form#class-submit-button > form').find('div') + cy.get('solid-form#class-submit-button > form') + .find('div') .should('have.attr', 'class', 'submitB-class') - .find('input[type="submit"]').should('exist'); - cy.get('solid-form#class-submit-button2 > form').find('div') + .find('input[type="submit"]') + .should('exist'); + cy.get('solid-form#class-submit-button2 > form') + .find('div') .should('have.attr', 'class', 'submitB-class2') - .find('button').should('exist'); + .find('button') + .should('exist'); }); -}) +}); diff --git a/cypress/e2e/e2e/solid-lang.cy.ts b/cypress/e2e/e2e/solid-lang.cy.ts index 742fbfbc..89fc3cb8 100644 --- a/cypress/e2e/e2e/solid-lang.cy.ts +++ b/cypress/e2e/e2e/solid-lang.cy.ts @@ -1,22 +1,22 @@ -describe('solid-lang', function() { +describe('solid-lang', function () { this.beforeEach('visit', () => { - cy.visit('/examples/e2e/solid-lang.html') + cy.visit('/examples/e2e/solid-lang.html'); }); - + it('test solid-lang', () => { // mark in window object to show reload - cy.window().then((w: any) => w.beforeReload = true) - + cy.window().then((w: any) => (w.beforeReload = true)); + // initilization of a property - cy.window().should('have.prop', 'beforeReload', true) - - - cy.contains('English').click().should(() => { - expect(localStorage.getItem('language')).to.eq('en') - }); + cy.window().should('have.prop', 'beforeReload', true); - // reload verification : if no property, it confirms the page reload - cy.window().should('not.have.prop', 'beforeReload') - }) -}) + cy.contains('English') + .click() + .should(() => { + expect(localStorage.getItem('language')).to.eq('en'); + }); + // reload verification : if no property, it confirms the page reload + cy.window().should('not.have.prop', 'beforeReload'); + }); +}); diff --git a/cypress/e2e/e2e/solid-map.cy.ts b/cypress/e2e/e2e/solid-map.cy.ts index 71468bf0..dcf5767b 100644 --- a/cypress/e2e/e2e/solid-map.cy.ts +++ b/cypress/e2e/e2e/solid-map.cy.ts @@ -1,60 +1,86 @@ -describe('solid-map', function() { +describe('solid-map', function () { this.beforeEach('visit', () => { - cy.visit('/examples/e2e/solid-map.html') - }) + cy.visit('/examples/e2e/solid-map.html'); + }); it('display markers', () => { - cy.get('#map-1 .leaflet-marker-pane').children().should('have.length', 6) - }) + cy.get('#map-1 .leaflet-marker-pane').children().should('have.length', 6); + }); it('display content in popup markers', () => { - cy.get('#map-2 .leaflet-marker-pane').children().first().click({force: true}) - cy.get('#map-2 .leaflet-popup-pane').children().should('have.length', 1) + cy.get('#map-2 .leaflet-marker-pane') + .children() + .first() + .click({ force: true }); + cy.get('#map-2 .leaflet-popup-pane').children().should('have.length', 1); cy.get('#map-2 .leaflet-popup-content solid-display') .should('have.length', 1) - .and('have.attr', 'data-src', '/examples/data/map/event-1.jsonld') - cy.get('#map-2 .leaflet-popup-content solid-display > div > solid-set-default') + .and('have.attr', 'data-src', '/examples/data/map/event-1.jsonld'); + cy.get( + '#map-2 .leaflet-popup-content solid-display > div > solid-set-default', + ) .should('have.length', 1) - .and('have.attr', 'name', 'infos') - cy.get('#map-2 .leaflet-popup-content solid-display > div > solid-set-default[name=infos] > solid-display-value').should('have.length', 2) - cy.get('#map-2 .leaflet-popup-content solid-display > div > solid-set-default[name=infos] > solid-display-value[name=name]').contains('Test 1') - cy.get('#map-2 .leaflet-popup-content solid-display > div > solid-set-default[name=infos] > solid-display-value[name=category]').contains('showcase event') - }) + .and('have.attr', 'name', 'infos'); + cy.get( + '#map-2 .leaflet-popup-content solid-display > div > solid-set-default[name=infos] > solid-display-value', + ).should('have.length', 2); + cy.get( + '#map-2 .leaflet-popup-content solid-display > div > solid-set-default[name=infos] > solid-display-value[name=name]', + ).contains('Test 1'); + cy.get( + '#map-2 .leaflet-popup-content solid-display > div > solid-set-default[name=infos] > solid-display-value[name=category]', + ).contains('showcase event'); + }); it('groups markers', () => { - cy.get('#map-3 .leaflet-marker-pane .group-meetup').should('have.length', 4) - cy.get('#map-3 .leaflet-marker-pane .group-showcaseevent').should('have.length', 2) - }) + cy.get('#map-3 .leaflet-marker-pane .group-meetup').should( + 'have.length', + 4, + ); + cy.get('#map-3 .leaflet-marker-pane .group-showcaseevent').should( + 'have.length', + 2, + ); + }); it('applies attributes', () => { - cy.get('#map-4 .leaflet-marker-pane').children().first().click({force: true}) + cy.get('#map-4 .leaflet-marker-pane') + .children() + .first() + .click({ force: true }); cy.get('#map-4 .leaflet-popup-content solid-display-div[name=name]') .should('have.length', 1) - .should('have.class', 'test-class-name') + .should('have.class', 'test-class-name'); cy.get('#map-4 .leaflet-popup-content solid-display-div[name=name] button') .should('have.length', 1) .contains('Modifier') - .click() - cy.get('#map-4 .leaflet-popup-content solid-display-div[name=name] > div') - .should('have.attr', "contenteditable") - }) + .click(); + cy.get( + '#map-4 .leaflet-popup-content solid-display-div[name=name] > div', + ).should('have.attr', 'contenteditable'); + }); it('filters markers', () => { - cy.get('#filter input[name=category]').type('showcase') - cy.get('#map-5 .leaflet-marker-pane').children().should('have.length', 2) - cy.get('#map-5 span#counter').contains('2 results') - cy.get('#filter input[name=category]').clear().type('mee') - cy.get('#map-5 .leaflet-marker-pane').children().should('have.length', 4) - cy.get('#map-5 span#counter').contains('4 results') - }) + cy.get('#filter input[name=category]').type('showcase'); + cy.get('#map-5 .leaflet-marker-pane').children().should('have.length', 2); + cy.get('#map-5 span#counter').contains('2 results'); + cy.get('#filter input[name=category]').clear().type('mee'); + cy.get('#map-5 .leaflet-marker-pane').children().should('have.length', 4); + cy.get('#map-5 span#counter').contains('4 results'); + }); it('markers clusters', () => { - cy.get('#map-6 .leaflet-marker-pane').children().should('have.length', 3) - cy.get('#map-6 .leaflet-marker-pane').children().eq(2) - .find('span').should('contain', '4') - }) + cy.get('#map-6 .leaflet-marker-pane').children().should('have.length', 3); + cy.get('#map-6 .leaflet-marker-pane') + .children() + .eq(2) + .find('span') + .should('contain', '4'); + }); it('display federated markers', () => { - cy.get('#map-federated .leaflet-marker-pane').children().should('have.length', 7) - }) -}) + cy.get('#map-federated .leaflet-marker-pane') + .children() + .should('have.length', 7); + }); +}); diff --git a/cypress/e2e/e2e/solid-table.cy.ts b/cypress/e2e/e2e/solid-table.cy.ts index 3c3b9e2c..46b23dc4 100644 --- a/cypress/e2e/e2e/solid-table.cy.ts +++ b/cypress/e2e/e2e/solid-table.cy.ts @@ -1,7 +1,7 @@ // TODO: We should make tests run independently of one another describe('solid-table', { testIsolation: false }, function () { this.beforeAll('visit', () => { - cy.visit('/examples/e2e/solid-table.html') + cy.visit('/examples/e2e/solid-table.html'); }); it('display users', () => { @@ -26,23 +26,27 @@ describe('solid-table', { testIsolation: false }, function () { // HEADER // Checkbox first - .children().eq(0) + .children() + .eq(0) .should('have.length', 1) .filter('input[type="checkbox"]') // Custom label .parents('tr') - .find('th').eq(1) + .find('th') + .eq(1) .should('contain', 'First Name') // Default label .parents('tr') - .find('th').eq(2) + .find('th') + .eq(2) .should('contain', 'last_name') // FIRST LINE .parents('table') - .find('tr').eq(1) + .find('tr') + .eq(1) .should('have.attr', 'data-resource', '/examples/data/list/user-3.jsonld') .children('td') .should('have.length', 5) @@ -55,13 +59,15 @@ describe('solid-table', { testIsolation: false }, function () { // First name .parents('tr') - .find('td').eq(1) + .find('td') + .eq(1) .find('solid-display-value') .should('have.text', 'Not A') // Custom widget .parents('tr') - .find('td').eq(3) + .find('td') + .eq(3) .find('solid-display-link-mailto') .find('a'); }); @@ -70,46 +76,55 @@ describe('solid-table', { testIsolation: false }, function () { cy.get('#table-users') // Line 2 - .find('input[type="checkbox"][data-selection]').eq(1) + .find('input[type="checkbox"][data-selection]') + .eq(1) .check() // Line 3 - .parents('table').find('input[type="checkbox"][data-selection]').eq(2) + .parents('table') + .find('input[type="checkbox"][data-selection]') + .eq(2) .check(); // Check data cy.get('#table-users').then($el => { expect((<any>$el[0]).component.selectedLines).to.deep.equal([ - '/examples/data/list/user-2.jsonld', '/examples/data/list/user-4.jsonld' - ]) + '/examples/data/list/user-2.jsonld', + '/examples/data/list/user-4.jsonld', + ]); }); // Select all - cy.get('#table-users') - .find('input[type="checkbox"]').eq(0).check(); + cy.get('#table-users').find('input[type="checkbox"]').eq(0).check(); cy.get('#table-users').then($el => { expect((<any>$el[0]).component.selectedLines).to.deep.equal([ - '/examples/data/list/user-3.jsonld', '/examples/data/list/user-2.jsonld', '/examples/data/list/user-4.jsonld', '/examples/data/list/user-1.jsonld' - ]) + '/examples/data/list/user-3.jsonld', + '/examples/data/list/user-2.jsonld', + '/examples/data/list/user-4.jsonld', + '/examples/data/list/user-1.jsonld', + ]); }); // Unselect all - cy.get('#table-users') - .find('input[type="checkbox"]').eq(0).uncheck(); + cy.get('#table-users').find('input[type="checkbox"]').eq(0).uncheck(); cy.get('#table-users').then($el => { - expect((<any>$el[0]).component.selectedLines).to.deep.equal([]) + expect((<any>$el[0]).component.selectedLines).to.deep.equal([]); }); }); it('orders lines', () => { cy.get('#table-users solid-display-value[name="first_name"]') - .eq(0).should('have.text', 'Not A'); + .eq(0) + .should('have.text', 'Not A'); cy.get('#table-users solid-display-value[name="first_name"]') - .eq(1).should('have.text', 'Paris'); + .eq(1) + .should('have.text', 'Paris'); cy.get('#table-users solid-display-value[name="first_name"]') - .eq(2).should('have.text', 'Pierre'); + .eq(2) + .should('have.text', 'Pierre'); cy.get('#table-users solid-display-value[name="first_name"]') - .eq(3).should('have.text', 'Test'); + .eq(3) + .should('have.text', 'Test'); }); it('shows user-1', () => { @@ -135,28 +150,33 @@ describe('solid-table', { testIsolation: false }, function () { .find('solid-display-value') .should('have.text', 'Test') // Last name - .parents('tr').find('td') + .parents('tr') + .find('td') .eq(1) .find('solid-display-value') .should('have.text', 'User') // email - .parents('tr').find('td') + .parents('tr') + .find('td') .eq(2) .find('solid-display-value') .should('have.text', 'test-user@example.com') // username - .parents('tr').find('td') + .parents('tr') + .find('td') .eq(3) .find('solid-display-value') - .should('have.text', 'admin') + .should('have.text', 'admin'); }); it('makes cells editable', () => { cy.get('#table-users-editable') - .find('tr').eq(0) + .find('tr') + .eq(0) // first_name - .find('td').eq(0) + .find('td') + .eq(0) .find('solid-form') .should('have.attr', 'data-src', '/examples/data/list/user-1.jsonld') .and('have.attr', 'fields', 'first_name') @@ -165,8 +185,10 @@ describe('solid-table', { testIsolation: false }, function () { .should('have.value', 'Test') // last_name - .parents('tr').eq(0) - .find('td').eq(1) + .parents('tr') + .eq(0) + .find('td') + .eq(1) .find('solid-form') .should('have.attr', 'data-src', '/examples/data/list/user-1.jsonld') .and('have.attr', 'fields', 'last_name') @@ -174,8 +196,10 @@ describe('solid-table', { testIsolation: false }, function () { .and('have.attr', 'partial', '') // email - .parents('tr').eq(0) - .find('td').eq(2) + .parents('tr') + .eq(0) + .find('td') + .eq(2) .find('solid-form') .should('have.attr', 'data-src', '/examples/data/list/user-1.jsonld') .and('have.attr', 'fields', 'email') @@ -189,18 +213,22 @@ describe('solid-table', { testIsolation: false }, function () { cy.get('#table-skills') // Line 2 (CSS) - .find('input[type="checkbox"][data-selection]').eq(1) + .find('input[type="checkbox"][data-selection]') + .eq(1) .check() // Line 3 (Javascript) - .parents('table').find('input[type="checkbox"][data-selection]').eq(2) + .parents('table') + .find('input[type="checkbox"][data-selection]') + .eq(2) .check(); // Check data cy.get('#table-skills').then($el => { expect((<any>$el[0]).component.selectedLines).to.deep.equal([ - '/examples/data/list/skill-2.jsonld', '/examples/data/list/skill-3.jsonld' - ]) + '/examples/data/list/skill-2.jsonld', + '/examples/data/list/skill-3.jsonld', + ]); }); // Order list @@ -209,112 +237,114 @@ describe('solid-table', { testIsolation: false }, function () { // Check data cy.get('#table-skills').then($el => { expect((<any>$el[0]).component.selectedLines).to.deep.equal([ - '/examples/data/list/skill-2.jsonld', '/examples/data/list/skill-3.jsonld' - ]) + '/examples/data/list/skill-2.jsonld', + '/examples/data/list/skill-3.jsonld', + ]); }); cy.get('#table-skills') // Line 1 (CSS) - .find('input[type="checkbox"][data-selection]').eq(0) + .find('input[type="checkbox"][data-selection]') + .eq(0) .should('be.checked') // Line 2 (DevOps) - .parents('table').find('input[type="checkbox"][data-selection]').eq(1) + .parents('table') + .find('input[type="checkbox"][data-selection]') + .eq(1) .should('not.be.checked') // Line 3 (Git) - .parents('table').find('input[type="checkbox"][data-selection]').eq(2) + .parents('table') + .find('input[type="checkbox"][data-selection]') + .eq(2) .should('not.be.checked') // Line 5 (Javascript) - .parents('table').find('input[type="checkbox"][data-selection]').eq(4) - .should('be.checked') + .parents('table') + .find('input[type="checkbox"][data-selection]') + .eq(4) + .should('be.checked'); }); it('numbers displayed', () => { cy.get('#table-skills') // Check numbers displayed - .find('solid-display-value[name="order"]').eq(0) - .should('be.visible').and('contain', '5'); + .find('solid-display-value[name="order"]') + .eq(0) + .should('be.visible') + .and('contain', '5'); }); - it('grouped ordered tables', () => { - cy.get('#grouped-table') - .within(() => { + cy.get('#grouped-table').within(() => { cy.get('solid-group-default').should('have.length', 4); cy.get('solid-group-default').each((item, index) => { if (index === 0) { - cy.wrap(item).find('span').contains('Opéra3') + cy.wrap(item).find('span').contains('Opéra3'); } if (index === 1) { - cy.wrap(item).find('span').contains('Opéra2') + cy.wrap(item).find('span').contains('Opéra2'); } if (index === 2) { - cy.wrap(item).find('span').contains('Opéra') + cy.wrap(item).find('span').contains('Opéra'); } - }); + }); }); - cy.get('#grouped-table-year-desc') - .within(() => { + cy.get('#grouped-table-year-desc').within(() => { cy.get('solid-group-default').should('have.length', 4); cy.get('solid-group-default').each((item, index) => { if (index === 0) { - cy.wrap(item).find('span').contains('2020') + cy.wrap(item).find('span').contains('2020'); } if (index === 1) { - cy.wrap(item).find('span').contains('2019') + cy.wrap(item).find('span').contains('2019'); } if (index === 2) { - cy.wrap(item).find('span').contains('2017') + cy.wrap(item).find('span').contains('2017'); } if (index === 3) { - cy.wrap(item).find('span').contains('2015') + cy.wrap(item).find('span').contains('2015'); } - }); + }); }); - cy.get('#grouped-table-year-asc') - .within(() => { + cy.get('#grouped-table-year-asc').within(() => { cy.get('solid-group-default').should('have.length', 4); cy.get('solid-group-default').each((item, index) => { if (index === 0) { - cy.wrap(item).find('span').contains('2015') + cy.wrap(item).find('span').contains('2015'); } if (index === 1) { - cy.wrap(item).find('span').contains('2017') + cy.wrap(item).find('span').contains('2017'); } if (index === 2) { - cy.wrap(item).find('span').contains('2019') + cy.wrap(item).find('span').contains('2019'); } if (index === 3) { - cy.wrap(item).find('span').contains('2020') + cy.wrap(item).find('span').contains('2020'); } - }); + }); }); - cy.get('#grouped-table-date-asc') - .within(() => { + cy.get('#grouped-table-date-asc').within(() => { cy.get('solid-group-default').should('have.length', 4); cy.get('solid-group-default').each((item, index) => { if (index === 0) { - cy.wrap(item).find('span').contains('2020-07-09') + cy.wrap(item).find('span').contains('2020-07-09'); } if (index === 1) { - cy.wrap(item).find('span').contains('2020-05-10') + cy.wrap(item).find('span').contains('2020-05-10'); } if (index === 2) { - cy.wrap(item).find('span').contains('2017-05-10') + cy.wrap(item).find('span').contains('2017-05-10'); } if (index === 3) { - cy.wrap(item).find('span').contains('2015-05-10') + cy.wrap(item).find('span').contains('2015-05-10'); } - }); + }); }); - - }); - -}) \ No newline at end of file +}); diff --git a/cypress/e2e/e2e/solid-widget.cy.ts b/cypress/e2e/e2e/solid-widget.cy.ts index 6800e7be..57f000ef 100644 --- a/cypress/e2e/e2e/solid-widget.cy.ts +++ b/cypress/e2e/e2e/solid-widget.cy.ts @@ -1,7 +1,7 @@ // TODO: We should make tests run independently of one another describe('solid-widget', { testIsolation: false }, function () { this.beforeAll('visit', () => { - cy.visit('/examples/e2e/solid-widget.html') + cy.visit('/examples/e2e/solid-widget.html'); }); // Display @@ -45,7 +45,6 @@ describe('solid-widget', { testIsolation: false }, function () { cy.get('#display-5') .find('custom-widget-5 span[name=value]') .should('have.text', 'next-view'); - }); // Form @@ -57,36 +56,45 @@ describe('solid-widget', { testIsolation: false }, function () { cy.get('#form-1').then($el => { return (<any>$el[0]).component.getFormValue().then(res => { expect(res).to.deep.equal({ - "email": "new-email@example.com" - }) - }) + email: 'new-email@example.com', + }); + }); }); }); it('form edition', () => { - cy.get('#form-2') - .find('custom-form-widget-2 input'); + cy.get('#form-2').find('custom-form-widget-2 input'); cy.get('#form-2').then($el => { return (<any>$el[0]).component.getFormValue().then(res => { expect(res).to.deep.equal({ - "email": "test-user@example.com", - "@id": "/examples/data/list/user-1.jsonld", - }) - }) + email: 'test-user@example.com', + '@id': '/examples/data/list/user-1.jsonld', + }); + }); }); }); it('form nested', () => { cy.get('#form-3') - .find('custom-form-widget-3').eq(0) + .find('custom-form-widget-3') + .eq(0) .find('solid-form') - .should('have.attr', 'data-src', '/examples/data/nested-forms/batch-1.jsonld'); + .should( + 'have.attr', + 'data-src', + '/examples/data/nested-forms/batch-1.jsonld', + ); cy.get('#form-3') - .find('custom-form-widget-3').eq(1) + .find('custom-form-widget-3') + .eq(1) .find('solid-form') - .should('have.attr', 'data-src', '/examples/data/nested-forms/batch-2.jsonld') + .should( + 'have.attr', + 'data-src', + '/examples/data/nested-forms/batch-2.jsonld', + ) .find('input[name=title]') .type(' automatique'); @@ -94,21 +102,22 @@ describe('solid-widget', { testIsolation: false }, function () { return (<any>$el[0]).component.getFormValue().then(res => { expect(res).to.deep.equal({ batches: { - "ldp:contains": [ + 'ldp:contains': [ { - title: "Développement", - "@id": "/examples/data/nested-forms/batch-1.jsonld" + title: 'Développement', + '@id': '/examples/data/nested-forms/batch-1.jsonld', }, { - title: "Déploiement automatique", - "@id": "/examples/data/nested-forms/batch-2.jsonld" - } + title: 'Déploiement automatique', + '@id': '/examples/data/nested-forms/batch-2.jsonld', + }, ], - "@id": "/examples/data/nested-forms/customer-invoice-1-batches.jsonld", + '@id': + '/examples/data/nested-forms/customer-invoice-1-batches.jsonld', }, - "@id": "/examples/data/nested-forms/customer-invoice-1.jsonld" - }) - }) + '@id': '/examples/data/nested-forms/customer-invoice-1.jsonld', + }); + }); }); }); diff --git a/cypress/e2e/e2e/translation.cy.ts b/cypress/e2e/e2e/translation.cy.ts index 20d71147..4f5507a6 100644 --- a/cypress/e2e/e2e/translation.cy.ts +++ b/cypress/e2e/e2e/translation.cy.ts @@ -3,86 +3,111 @@ describe('translation', function () { cy.visit('/examples/e2e/translation.html', { onBeforeLoad(win) { Object.defineProperty(win.navigator, 'language', { - value: 'fr' - }) - } + value: 'fr', + }); + }, }); }); it('French translation in validation attributes, submit buttons, autocompletion mixin', () => { // french in confirm and buttons const stub = cy.stub(); - cy.on('window:confirm', stub) + cy.on('window:confirm', stub); cy.get('solid-delete#confirm') - .find('button').should('contain', 'Supprimer') + .find('button') + .should('contain', 'Supprimer') .click() .then(() => { - expect(stub.getCall(0)).to.be.calledWith('Merci de confirmer votre choix'); + expect(stub.getCall(0)).to.be.calledWith( + 'Merci de confirmer votre choix', + ); }); cy.get('solid-form#void-submitbutton') - .find('input[type=submit]').should('contain', 'Envoyer'); + .find('input[type=submit]') + .should('contain', 'Envoyer'); // french in dialog, buttons customized cy.get('solid-delete#dialog') - .find('button').should('contain', 'Delete data'); + .find('button') + .should('contain', 'Delete data'); cy.get('solid-delete#dialog > dialog') .should('contain', 'Merci de confirmer votre choix') .and('contain', 'Oui') .and('contain', 'Annuler'); cy.get('solid-form#custom-submitbutton') - .find('input[type=submit]').should('contain', 'Send form'); + .find('input[type=submit]') + .should('contain', 'Send form'); // french in autompletion multipleselect cy.get('solid-form-search#translation-autocomp') - .find('.ss-placeholder').filter(":visible").should('contain', 'Sélectionner une valeur') + .find('.ss-placeholder') + .filter(':visible') + .should('contain', 'Sélectionner une valeur') .click(); cy.get('.ss-content') - .find('.ss-search').filter(":visible").children().should('have.attr', 'placeholder', 'Rechercher') - .wait(200).type('00'); + .find('.ss-search') + .filter(':visible') + .children() + .should('have.attr', 'placeholder', 'Rechercher') + .wait(200) + .type('00'); cy.get('.ss-content') - .find('.ss-list').children().contains('Aucun résultat') + .find('.ss-list') + .children() + .contains('Aucun résultat'); }); it('English translation in validation attributes, submit buttons, autocompletion mixin', () => { cy.get('#en').click(); // english in confirm and buttons const stub = cy.stub(); - cy.on('window:confirm', stub) + cy.on('window:confirm', stub); cy.get('solid-delete#confirm') - .find('button').should('contain', 'Delete') + .find('button') + .should('contain', 'Delete') .click() .then(() => { expect(stub.getCall(0)).to.be.calledWith('Please, confirm your choice'); }); cy.get('solid-form#void-submitbutton') - .find('input[type=submit]').should('contain', 'Submit'); + .find('input[type=submit]') + .should('contain', 'Submit'); // english in dialog, buttons customized cy.get('solid-delete#dialog') - .find('button').should('contain', 'Delete data'); + .find('button') + .should('contain', 'Delete data'); cy.get('solid-delete#dialog > dialog') .should('contain', 'Please, confirm your choice') .and('contain', 'Yes') .and('contain', 'Cancel'); cy.get('solid-form#custom-submitbutton') - .find('input[type=submit]').should('contain', 'Send form'); + .find('input[type=submit]') + .should('contain', 'Send form'); // english in autompletion multipleselect cy.get('solid-form-search#translation-autocomp') - .find('.ss-placeholder').filter(":visible").should('contain', 'Select a value') + .find('.ss-placeholder') + .filter(':visible') + .should('contain', 'Select a value') .click(); cy.get('.ss-content') - .find('.ss-search').filter(":visible").children().should('have.attr', 'placeholder', 'Search') - .wait(200).type('00'); - cy.get('.ss-content') - .find('.ss-list').children().contains('No result') + .find('.ss-search') + .filter(':visible') + .children() + .should('have.attr', 'placeholder', 'Search') + .wait(200) + .type('00'); + cy.get('.ss-content').find('.ss-list').children().contains('No result'); }); it('Missing translation file', () => { cy.get('#fr').find('button').click(); - cy.get('solid-delete#confirm').find('button').should('contain', 'Supprimer'); + cy.get('solid-delete#confirm') + .find('button') + .should('contain', 'Supprimer'); // Asking to get a missing file, English loaded by default cy.get('#it').find('button').click(); cy.get('solid-delete#confirm').find('button').should('contain', 'Delete'); - }) -}); \ No newline at end of file + }); +}); diff --git a/cypress/e2e/e2e/validation.cy.ts b/cypress/e2e/e2e/validation.cy.ts index 00cbac81..7afb4d81 100644 --- a/cypress/e2e/e2e/validation.cy.ts +++ b/cypress/e2e/e2e/validation.cy.ts @@ -5,9 +5,9 @@ describe('validation', function () { cy.visit('/examples/e2e/validation.html', { onBeforeLoad(win) { Object.defineProperty(win.navigator, 'language', { - value: 'en' - }) - } + value: 'en', + }); + }, }); cy.window().then(w => { win = w; @@ -17,105 +17,136 @@ describe('validation', function () { it('confirm popup on solid-delete', () => { const stub = cy.stub(); - cy.on('window:confirm', stub) + cy.on('window:confirm', stub); cy.get('solid-delete#confirm') .should('have.attr', 'confirmation-type', 'confirm') - .and('have.attr', 'confirmation-message') + .and('have.attr', 'confirmation-message'); cy.get('solid-delete#confirm') .find('button') .click() .then(() => { - expect(stub.getCall(0)).to.be.calledWith('Are you sure ?') + expect(stub.getCall(0)).to.be.calledWith('Are you sure ?'); }); }); it('confirm popup on solid-form', () => { const stub = cy.stub(); - cy.on('window:confirm', stub) + cy.on('window:confirm', stub); cy.get('solid-form#confirm') .find('input[type=submit]') .click() .then(() => { - expect(stub.getCall(0)).to.be.calledWith('Please, confirm your choice') //message by default displayed in English translation + expect(stub.getCall(0)).to.be.calledWith('Please, confirm your choice'); //message by default displayed in English translation }); }); it('dialog popup on solid-form', () => { // simple dialog popup cy.get('solid-form#simple-dialog > dialog') - .find('p').should('contain', 'Please, confirm your choice')//message by default displayed in English translation - cy.get('solid-form#simple-dialog > dialog > div').children().eq(0) - .should('contain', 'Yes') - cy.get('solid-form#simple-dialog > dialog > div').children().eq(1) - .should('contain', 'Cancel') + .find('p') + .should('contain', 'Please, confirm your choice'); //message by default displayed in English translation + cy.get('solid-form#simple-dialog > dialog > div') + .children() + .eq(0) + .should('contain', 'Yes'); + cy.get('solid-form#simple-dialog > dialog > div') + .children() + .eq(1) + .should('contain', 'Cancel'); cy.get('solid-form#simple-dialog > dialog') - .find('button').should('have.not.attr', 'class') + .find('button') + .should('have.not.attr', 'class'); //custom dialog popup cy.get('solid-form#custom-dialog > dialog') - .find('p').should('contain', 'Custom message : Are you sure ?') - cy.get('solid-form#custom-dialog > dialog > div').children().eq(0) + .find('p') + .should('contain', 'Custom message : Are you sure ?'); + cy.get('solid-form#custom-dialog > dialog > div') + .children() + .eq(0) .should('contain', 'Certainly') - .and('have.attr', 'class', 'submit-button') - cy.get('solid-form#custom-dialog > dialog > div').children().eq(1) + .and('have.attr', 'class', 'submit-button'); + cy.get('solid-form#custom-dialog > dialog > div') + .children() + .eq(1) .should('contain', 'Quit') - .and('have.attr', 'class', 'cancel-button') + .and('have.attr', 'class', 'cancel-button'); }); it('actions on dialog popup', () => { //dialog modal correctly opened and closed with buttons - cy.get('solid-form#custom-dialog > form > solid-form-label-text > input') - .type('{selectall}Presentation') - cy.get('solid-form#custom-dialog > form > div > input').click() - cy.get('solid-form#custom-dialog > dialog') - .should('have.attr', 'open') + cy.get( + 'solid-form#custom-dialog > form > solid-form-label-text > input', + ).type('{selectall}Presentation'); + cy.get('solid-form#custom-dialog > form > div > input').click(); + cy.get('solid-form#custom-dialog > dialog').should('have.attr', 'open'); - cy.get('solid-form#custom-dialog > dialog > div').children().eq(1).click() - cy.get('solid-form#custom-dialog > dialog') - .should('not.have.attr', 'open') - cy.get('solid-form#custom-dialog > form > div > input').click() - cy.get('solid-form#custom-dialog > dialog') - .should('have.attr', 'open') + cy.get('solid-form#custom-dialog > dialog > div').children().eq(1).click(); + cy.get('solid-form#custom-dialog > dialog').should('not.have.attr', 'open'); + cy.get('solid-form#custom-dialog > form > div > input').click(); + cy.get('solid-form#custom-dialog > dialog').should('have.attr', 'open'); //form well sent, data well deleted cy.spy(win.sibStore, 'post'); - cy.get('solid-form#custom-dialog > dialog > div').children().eq(0).click().then(() => { - expect(win.sibStore.post).to.be.called; - cy.get('solid-form#custom-dialog > dialog') - .should('not.have.attr', 'open') - }); + cy.get('solid-form#custom-dialog > dialog > div') + .children() + .eq(0) + .click() + .then(() => { + expect(win.sibStore.post).to.be.called; + cy.get('solid-form#custom-dialog > dialog').should( + 'not.have.attr', + 'open', + ); + }); cy.spy(win.sibStore, 'delete'); - cy.get('solid-delete#delete-data > dialog > div').children().eq(0).click({ force: true }).then(() => { - expect(win.sibStore.delete).to.be.called; - cy.get('solid-delete#delete-data > dialog') - .should('not.have.attr', 'open') - }); + cy.get('solid-delete#delete-data > dialog > div') + .children() + .eq(0) + .click({ force: true }) + .then(() => { + expect(win.sibStore.delete).to.be.called; + cy.get('solid-delete#delete-data > dialog').should( + 'not.have.attr', + 'open', + ); + }); }); it('confirmation-type missing', () => { cy.spy(cnsl, 'warn'); - cy.get('solid-delete#missing-type').find('button').click().then(() => { - expect(cnsl.warn).to.be.called; - }); + cy.get('solid-delete#missing-type') + .find('button') + .click() + .then(() => { + expect(cnsl.warn).to.be.called; + }); }); it('confirmation widget', () => { cy.get('solid-form#confirmation-widget') .find('dialog') - .find('my-widget-confirm').should('have.attr', 'value', '/examples/data/project.jsonld') - .find('solid-display-value').should('have.attr', 'value', 'Envoyer une fusée') - cy.get('solid-form#confirmation-widget > form > div > input') - .click() + .find('my-widget-confirm') + .should('have.attr', 'value', '/examples/data/project.jsonld') + .find('solid-display-value') + .should('have.attr', 'value', 'Envoyer une fusée'); + cy.get('solid-form#confirmation-widget > form > div > input').click(); cy.get('solid-form#confirmation-widget') - .find('dialog').should('contain', 'Envoyer une fusée') - .find('div').children().eq(1).click(); + .find('dialog') + .should('contain', 'Envoyer une fusée') + .find('div') + .children() + .eq(1) + .click(); cy.get('solid-delete#confirmation-widget') .find('dialog') - .find('my-widget-confirm2').should('have.attr', 'value', '/examples/data/project.jsonld') - .find('solid-display-value').should('have.attr', 'value', 'Envoyer une fusée') - cy.get('solid-delete#confirmation-widget > button') - .click() + .find('my-widget-confirm2') + .should('have.attr', 'value', '/examples/data/project.jsonld') + .find('solid-display-value') + .should('have.attr', 'value', 'Envoyer une fusée'); + cy.get('solid-delete#confirmation-widget > button').click(); cy.get('solid-delete#confirmation-widget') - .find('dialog').should('contain', 'Envoyer une fusée') - }) -}); \ No newline at end of file + .find('dialog') + .should('contain', 'Envoyer une fusée'); + }); +}); diff --git a/cypress/e2e/e2e/widgets-custom.cy.ts b/cypress/e2e/e2e/widgets-custom.cy.ts index f1785d36..6ab4beef 100644 --- a/cypress/e2e/e2e/widgets-custom.cy.ts +++ b/cypress/e2e/e2e/widgets-custom.cy.ts @@ -1,7 +1,7 @@ describe('custom widgets', function () { this.beforeEach('visit', () => { - cy.visit('/examples/e2e/widgets-custom.html') - }) + cy.visit('/examples/e2e/widgets-custom.html'); + }); it('set value', () => { cy.get('solid-display#test1') @@ -9,12 +9,12 @@ describe('custom widgets', function () { .should('have.length', 1) .find('h1') .should('contain', 'Envoyer une fusée'); - }) + }); it('set attributes', () => { cy.get('solid-display#test2') .find('custom-widget') .should('have.length', 1) - .and('have.attr', 'class', 'test-class') - }) -}) + .and('have.attr', 'class', 'test-class'); + }); +}); diff --git a/cypress/e2e/e2e/widgets-display-multiple.cy.ts b/cypress/e2e/e2e/widgets-display-multiple.cy.ts index 595a285e..a1b8d4d5 100644 --- a/cypress/e2e/e2e/widgets-display-multiple.cy.ts +++ b/cypress/e2e/e2e/widgets-display-multiple.cy.ts @@ -1,6 +1,6 @@ -describe('multiple widgets', function() { +describe('multiple widgets', function () { this.beforeEach('visit', () => { - cy.visit('/examples/e2e/widgets-display-multiple.html') + cy.visit('/examples/e2e/widgets-display-multiple.html'); }); it('solid-display-multiple and empty widget', () => { @@ -9,14 +9,17 @@ describe('multiple widgets', function() { .find('empty-skills') .should('contain', 'This username has no skills'); cy.get('solid-multiple#noskill > solid-display > span') - .children().should('have.length', 1); + .children() + .should('have.length', 1); cy.get('solid-multiple#skills') .should('have.attr', 'empty-widget', 'empty-skills') - .find('solid-display-value') + .find('solid-display-value'); cy.get('solid-multiple#skills > solid-display > div') - .children().should('have.length', 2); + .children() + .should('have.length', 2); cy.get('solid-multiple#skills > solid-display > span') - .children().should('not.exist') + .children() + .should('not.exist'); }); -}) +}); diff --git a/cypress/e2e/e2e/widgets-display.cy.ts b/cypress/e2e/e2e/widgets-display.cy.ts index 3ba5dfd5..dd85fccd 100644 --- a/cypress/e2e/e2e/widgets-display.cy.ts +++ b/cypress/e2e/e2e/widgets-display.cy.ts @@ -1,36 +1,36 @@ describe('display widgets', function () { this.beforeEach('visit', () => { - cy.visit('/examples/e2e/widgets-display.html') - }) + cy.visit('/examples/e2e/widgets-display.html'); + }); it('solid-display-value', () => { cy.get('solid-display-value') .should('contain', 'test value 1') - .children().should('have.length', 0); - }) + .children() + .should('have.length', 0); + }); it('solid-display-div', () => { cy.get('solid-display-div#test1') .should('contain', 'test value 1') .find('> div') .should('have.length', 1) - .should('have.attr', 'name', 'test1') - }) + .should('have.attr', 'name', 'test1'); + }); it('solid-display-div editable', () => { - cy.intercept("PATCH", '**/resource-1.jsonld', { + cy.intercept('PATCH', '**/resource-1.jsonld', { headers: { - contentType: 'application/ld+json' - } - }) - cy.intercept("GET", '**/resource-1.jsonld', { + contentType: 'application/ld+json', + }, + }); + cy.intercept('GET', '**/resource-1.jsonld', { headers: { - contentType: 'application/ld+json' - } - }) - - cy.get('solid-display-div#test2') - .children().should('have.length', 2); + contentType: 'application/ld+json', + }, + }); + + cy.get('solid-display-div#test2').children().should('have.length', 2); cy.get('solid-display-div#test2') .find('> div') .should('have.attr', 'data-editable', ''); @@ -50,8 +50,8 @@ describe('display widgets', function () { .should('have.length', 1) .and('have.attr', 'name', 'test1') .and('have.attr', 'href', 'http://example.com') - .and('contain', 'http://example.com') - }) + .and('contain', 'http://example.com'); + }); it('solid-display-link-mailto', () => { cy.get('solid-display-link-mailto') @@ -59,19 +59,19 @@ describe('display widgets', function () { .should('have.length', 1) .and('have.attr', 'name', 'test1') .and('have.attr', 'href', 'mailto:http://example.com') - .and('contain', 'http://example.com') - }) + .and('contain', 'http://example.com'); + }); it('solid-display-link-mailto-label', () => { cy.get('solid-display-link-mailto-label') .find('label') - .should('contain', 'mail: ') + .should('contain', 'mail: '); cy.get('solid-display-link-mailto-label') .find('a') .should('have.attr', 'name', 'test1') .and('have.attr', 'href', 'mailto:http://example.com') - .and('contain', 'http://example.com') - }) + .and('contain', 'http://example.com'); + }); it('solid-display-link-tel', () => { cy.get('solid-display-link-tel') @@ -79,19 +79,19 @@ describe('display widgets', function () { .should('have.length', 1) .and('have.attr', 'name', 'test1') .and('have.attr', 'href', 'tel:http://example.com') - .and('contain', 'http://example.com') - }) + .and('contain', 'http://example.com'); + }); it('solid-display-link-tel-label', () => { cy.get('solid-display-link-tel-label') .find('label') - .should('contain', 'tel: ') + .should('contain', 'tel: '); cy.get('solid-display-link-tel-label') .find('a') .should('have.attr', 'name', 'test1') .and('have.attr', 'href', 'tel:http://example.com') - .and('contain', 'http://example.com') - }) + .and('contain', 'http://example.com'); + }); it('solid-display-link-blank', () => { cy.get('solid-display-link-blank') @@ -101,19 +101,19 @@ describe('display widgets', function () { .and('have.attr', 'href', 'http://example.com') .and('have.attr', 'target', '_blank') .and('have.attr', 'link-text', 'link text') - .and('contain', 'link text') - }) - + .and('contain', 'link text'); + }); + it('solid-display-link-blank-label', () => { cy.get('solid-display-link-blank-label') .find('label') - .should('contain', 'blank test: ') + .should('contain', 'blank test: '); cy.get('solid-display-link-blank-label') .find('a') .should('have.attr', 'name', 'test1') .and('have.attr', 'href', 'http://example.com') - .and('contain', 'http://example.com') - }) + .and('contain', 'http://example.com'); + }); it('solid-display-img', () => { cy.get('solid-display-img') @@ -121,8 +121,8 @@ describe('display widgets', function () { .should('have.length', 1) .and('have.attr', 'name', 'test1') .and('have.attr', 'src', 'test-img.png') - .and('have.attr', 'alt', 'alternative text') - }) + .and('have.attr', 'alt', 'alternative text'); + }); it('solid-display-boolean', () => { cy.get('solid-display-boolean[name=test1]') @@ -131,9 +131,9 @@ describe('display widgets', function () { .and('contain', 'Is displayed ?'); cy.get('solid-display-boolean[name=test2]') .find('label') - .should('not.exist') - }) - + .should('not.exist'); + }); + it('solid-display-label-div', () => { cy.get('solid-display-label-div[name=test1]') .find('label') @@ -152,7 +152,7 @@ describe('display widgets', function () { .find('> div') .should('have.length', 1) .and('contain', 'test value 1'); - }) + }); it('solid-display-date-div', () => { cy.get('solid-display-date-div') @@ -162,7 +162,7 @@ describe('display widgets', function () { .and('contain', '28') .and('contain', '5') .and('contain', '2020'); - }) + }); it('solid-display-datetime-div', () => { cy.get('solid-display-datetime-div') @@ -174,14 +174,14 @@ describe('display widgets', function () { .and('contain', '2020') .and('contain', '00') .and('contain', ':'); - }) + }); it('solid-display-multiline-div', () => { cy.get('solid-display-multiline-div') .find('> div') .should('have.length', 1) - .and('contain.html', '<br>') - }) + .and('contain.html', '<br>'); + }); it('solid-multiple', () => { cy.get('solid-multiple') @@ -195,34 +195,36 @@ describe('display widgets', function () { .and('contain', 'CSS') .and('contain', 'Javascript') .and('not.contain', 'DevOps') - .and('not.contain', 'HTML') - }) + .and('not.contain', 'HTML'); + }); it('solid-action', () => { - cy.get('solid-action').first() + cy.get('solid-action') + .first() .find('solid-link') .should('have.attr', 'data-src', 'resource-1.jsonld') .and('have.attr', 'next', 'next-page') .and('contain', 'test1'); - }) + }); it('solid-action', () => { - cy.get('solid-action').last() + cy.get('solid-action') + .last() .find('solid-link') .should('have.attr', 'data-src', 'resource-1.jsonld') .and('have.attr', 'next', 'next-page') .and('contain', 'link text'); - }) + }); it('solid-action-label', () => { cy.get('solid-action-label') .find('label') - .should('contain', 'label solid-action: ') + .should('contain', 'label solid-action: '); cy.get('solid-action-label') .find('solid-link') .should('have.attr', 'data-src', 'resource-1.jsonld') .and('have.attr', 'next', 'next-page') .and('contain', 'test1'); - }) + }); it('solid-display-div-markdown', () => { cy.get('solid-display-div-markdown') @@ -231,9 +233,7 @@ describe('display widgets', function () { cy.get('solid-display-div-markdown') .find('strong') .should('contain', 'bold'); - cy.get('solid-display-div-markdown') - .find('em') - .should('contain', 'italic'); + cy.get('solid-display-div-markdown').find('em').should('contain', 'italic'); cy.get('solid-display-div-markdown') .find('a') .should('contain', 'link') @@ -242,40 +242,54 @@ describe('display widgets', function () { // Change value to something else cy.get('solid-display-div-markdown') .invoke('attr', 'value', '**bold** [link](http://corndog.io/)') - .find('em').should('not.exist'); + .find('em') + .should('not.exist'); // Change value to empty cy.get('solid-display-div-markdown') .invoke('attr', 'value', '') .find('div[name="test display markdown"]') - .children().should('have.length', 0) + .children() + .should('have.length', 0); }); - + it('solid-display-div-autolink', () => { - cy.get('solid-display-div-autolink > div').children() + cy.get('solid-display-div-autolink > div') + .children() .should('have.length', 2); - cy.get('solid-display-div-autolink > div').children().eq(0) + cy.get('solid-display-div-autolink > div') + .children() + .eq(0) .should('have.attr', 'href', 'http://www.w3.org'); - cy.get('solid-display-div-autolink > div').children().eq(1) - .should('have.attr', 'href', 'http://www.window-swap.com') + cy.get('solid-display-div-autolink > div') + .children() + .eq(1) + .should('have.attr', 'href', 'http://www.window-swap.com'); }); it('solid-display-value-oembed', () => { - cy.intercept("GET", 'https://ldp-server2.test/oembed/', { + cy.intercept('GET', 'https://ldp-server2.test/oembed/', { headers: { - contentType: 'application/ld+json' - }, fixture: "oembed.jsonld" + contentType: 'application/ld+json', + }, + fixture: 'oembed.jsonld', + }); - }) - - cy.get('solid-display-value-oembed').children() - .should('have.length', 1); + cy.get('solid-display-value-oembed').children().should('have.length', 1); cy.get('solid-display-value-oembed > iframe') - .should('have.attr', 'src', 'https://www.youtube.com/embed/M3r2XDceM6A?feature=oembed') + .should( + 'have.attr', + 'src', + 'https://www.youtube.com/embed/M3r2XDceM6A?feature=oembed', + ) .and('have.attr', 'width', '200') .and('have.attr', 'height', '113') .and('have.attr', 'frameborder', '0') - .and('have.attr', 'allow', 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share') + .and( + 'have.attr', + 'allow', + 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share', + ) .and('have.attr', 'allowfullscreen'); }); -}) +}); diff --git a/cypress/e2e/e2e/widgets-form-multiple.cy.ts b/cypress/e2e/e2e/widgets-form-multiple.cy.ts index db21b1cd..2851f130 100644 --- a/cypress/e2e/e2e/widgets-form-multiple.cy.ts +++ b/cypress/e2e/e2e/widgets-form-multiple.cy.ts @@ -1,12 +1,11 @@ // TODO: We should make tests run independently of one another describe('multiple widgets', { testIsolation: false }, function () { this.beforeAll('visit', () => { - cy.visit('/examples/e2e/widgets-form-multiple.html') - }) + cy.visit('/examples/e2e/widgets-form-multiple.html'); + }); it('solid-form-multiple', () => { - cy.get('solid-form-multiple#test1') - .children().should('have.length', 1); + cy.get('solid-form-multiple#test1').children().should('have.length', 1); cy.get('solid-form-multiple#test1') .find('button') @@ -14,18 +13,18 @@ describe('multiple widgets', { testIsolation: false }, function () { .click(); // add a line // Check new line - cy.get('solid-form-multiple#test1') - .children().should('have.length', 2); + cy.get('solid-form-multiple#test1').children().should('have.length', 2); cy.get('solid-form-multiple#test1 > div[data-index="test0"]') - .children().should('have.length', 2); + .children() + .should('have.length', 2); cy.get('solid-form-multiple#test1 > div[data-index="test0"]') .find('solid-form-text') .should('have.attr', 'data-holder', '') .should('have.attr', 'value', '') .should('have.attr', 'range', '') - .should('have.attr', 'name', 'test') + .should('have.attr', 'name', 'test'); // Remove line cy.get('solid-form-multiple#test1 > div[data-index="test0"]') @@ -33,22 +32,21 @@ describe('multiple widgets', { testIsolation: false }, function () { .should('contain', '×') .click(); - cy.get('solid-form-multiple#test1') - .children().should('have.length', 1); - cy.get('solid-form-multiple#test1 > div[data-index="test0"]').should('not.exist') - }) + cy.get('solid-form-multiple#test1').children().should('have.length', 1); + cy.get('solid-form-multiple#test1 > div[data-index="test0"]').should( + 'not.exist', + ); + }); it('solid-form-multiple and range', () => { - cy.get('solid-form-multiple#test2') - .find('button').contains('+') - .click(); // add a line + cy.get('solid-form-multiple#test2').find('button').contains('+').click(); // add a line // Check new line - cy.get('solid-form-multiple#test2') - .children().should('have.length', 2); + cy.get('solid-form-multiple#test2').children().should('have.length', 2); cy.get('solid-form-multiple#test2 > div[data-index="test0"]') - .children().should('have.length', 2); + .children() + .should('have.length', 2); cy.get('solid-form-multiple#test2 > div[data-index="test0"]') // check attributes .find('solid-form-dropdown') @@ -56,32 +54,43 @@ describe('multiple widgets', { testIsolation: false }, function () { .should('have.attr', 'value', '') .should('have.attr', 'range', '/examples/data/list/skills.jsonld') .should('have.attr', 'data-src', '/examples/data/list/skills.jsonld') - .should('have.attr', 'name', 'test') + .should('have.attr', 'name', 'test'); - cy.get('solid-form-multiple#test2 > div[data-index="test0"] solid-form-dropdown') + cy.get( + 'solid-form-multiple#test2 > div[data-index="test0"] solid-form-dropdown', + ) .find('select > option') // check options .should('have.length', 9) - .eq(4).should('contain', 'DevOps'); + .eq(4) + .should('contain', 'DevOps'); // add 2 new lines cy.get('solid-form-multiple#test2') - .find('button').contains('+') + .find('button') + .contains('+') .click() .click(); cy.get('solid-form-multiple#test2') // check children added - .children().should('have.length', 4); + .children() + .should('have.length', 4); - cy.get('solid-form-multiple#test2 > div[data-index="test1"] solid-form-dropdown') - .find('select > option').should('have.length', 9); // check options of children + cy.get( + 'solid-form-multiple#test2 > div[data-index="test1"] solid-form-dropdown', + ) + .find('select > option') + .should('have.length', 9); // check options of children // Select values - cy.get('solid-form-multiple#test2 > div[data-index="test0"] solid-form-dropdown > select') - .select('DevOps'); - cy.get('solid-form-multiple#test2 > div[data-index="test1"] solid-form-dropdown > select') - .select('HTML'); - cy.get('solid-form-multiple#test2 > div[data-index="test2"] solid-form-dropdown > select') - .select('Javascript'); + cy.get( + 'solid-form-multiple#test2 > div[data-index="test0"] solid-form-dropdown > select', + ).select('DevOps'); + cy.get( + 'solid-form-multiple#test2 > div[data-index="test1"] solid-form-dropdown > select', + ).select('HTML'); + cy.get( + 'solid-form-multiple#test2 > div[data-index="test2"] solid-form-dropdown > select', + ).select('Javascript'); // Remove line cy.get('solid-form-multiple#test2 > div[data-index="test0"]') @@ -90,62 +99,104 @@ describe('multiple widgets', { testIsolation: false }, function () { .click(); cy.get('solid-form-multiple#test2') // check children - .children().should('have.length', 3); - cy.get('solid-form-multiple#test2 > div[data-index="test0"]').should('not.exist') - cy.get('solid-form-multiple#test2 > div[data-index="test1"]').should('exist') - cy.get('solid-form-multiple#test2 > div[data-index="test2"]').should('exist') + .children() + .should('have.length', 3); + cy.get('solid-form-multiple#test2 > div[data-index="test0"]').should( + 'not.exist', + ); + cy.get('solid-form-multiple#test2 > div[data-index="test1"]').should( + 'exist', + ); + cy.get('solid-form-multiple#test2 > div[data-index="test2"]').should( + 'exist', + ); // Check select values still here - cy.get('solid-form-multiple#test2 > div[data-index="test1"] select') - .should('have.value', '{"@id": "/examples/data/list/skill-1.jsonld"}'); - cy.get('solid-form-multiple#test2 > div[data-index="test2"] select') - .should('have.value', '{"@id": "/examples/data/list/skill-3.jsonld"}'); + cy.get('solid-form-multiple#test2 > div[data-index="test1"] select').should( + 'have.value', + '{"@id": "/examples/data/list/skill-1.jsonld"}', + ); + cy.get('solid-form-multiple#test2 > div[data-index="test2"] select').should( + 'have.value', + '{"@id": "/examples/data/list/skill-3.jsonld"}', + ); // Check widget value - cy.get('solid-form-multiple#test2').then($el => { // Check API + cy.get('solid-form-multiple#test2').then($el => { + // Check API expect((<any>$el[0]).component.value).to.equal(''); // value attribute - expect((<any>$el[0]).component.getValue()).to.deep.equal(['{"@id": "/examples/data/list/skill-1.jsonld"}', '{"@id": "/examples/data/list/skill-3.jsonld"}']); // form value + expect((<any>$el[0]).component.getValue()).to.deep.equal([ + '{"@id": "/examples/data/list/skill-1.jsonld"}', + '{"@id": "/examples/data/list/skill-3.jsonld"}', + ]); // form value }); - }) + }); it('solid-form-multiple and value', () => { cy.get('solid-form-multiple#test3') // check data-src - .should('have.attr', 'data-src', '/examples/data/list/user-1-skills.jsonld') - .children().should('have.length', 3); - - cy.get('solid-form-multiple#test3 > button') - .should('contain', 'add'); - cy.get('solid-form-multiple#test3 > div[data-index="test0"] > button') - .should('contain', 'remove'); - - cy.get('solid-form-multiple#test3 > div[data-index="test0"] solid-form-dropdown') - .should('have.attr', 'value', '/examples/data/list/skill-2.jsonld'); - cy.get('solid-form-multiple#test3 > div[data-index="test1"] solid-form-dropdown') - .should('have.attr', 'value', '/examples/data/list/skill-3.jsonld'); + .should( + 'have.attr', + 'data-src', + '/examples/data/list/user-1-skills.jsonld', + ) + .children() + .should('have.length', 3); + + cy.get('solid-form-multiple#test3 > button').should('contain', 'add'); + cy.get( + 'solid-form-multiple#test3 > div[data-index="test0"] > button', + ).should('contain', 'remove'); + + cy.get( + 'solid-form-multiple#test3 > div[data-index="test0"] solid-form-dropdown', + ).should('have.attr', 'value', '/examples/data/list/skill-2.jsonld'); + cy.get( + 'solid-form-multiple#test3 > div[data-index="test1"] solid-form-dropdown', + ).should('have.attr', 'value', '/examples/data/list/skill-3.jsonld'); // Check widget value - cy.get('solid-form-multiple#test3').then($el => { // Check API - expect((<any>$el[0]).component.value).to.equal('/examples/data/list/user-1-skills.jsonld'); // value attribute - expect((<any>$el[0]).component.getValue()).to.deep.equal(['{"@id": "/examples/data/list/skill-2.jsonld"}', '{"@id": "/examples/data/list/skill-3.jsonld"}']); // form value + cy.get('solid-form-multiple#test3').then($el => { + // Check API + expect((<any>$el[0]).component.value).to.equal( + '/examples/data/list/user-1-skills.jsonld', + ); // value attribute + expect((<any>$el[0]).component.getValue()).to.deep.equal([ + '{"@id": "/examples/data/list/skill-2.jsonld"}', + '{"@id": "/examples/data/list/skill-3.jsonld"}', + ]); // form value }); - cy.get('solid-form-multiple#test3 > div[data-index="test1"] button').click(); //remove line - - cy.get('solid-form-multiple#test3').then($el => { // Check API - expect((<any>$el[0]).component.value).to.equal('/examples/data/list/user-1-skills.jsonld'); // value attribute - expect((<any>$el[0]).component.getValue()).to.deep.equal(['{"@id": "/examples/data/list/skill-2.jsonld"}']); // form value + cy.get( + 'solid-form-multiple#test3 > div[data-index="test1"] button', + ).click(); //remove line + + cy.get('solid-form-multiple#test3').then($el => { + // Check API + expect((<any>$el[0]).component.value).to.equal( + '/examples/data/list/user-1-skills.jsonld', + ); // value attribute + expect((<any>$el[0]).component.getValue()).to.deep.equal([ + '{"@id": "/examples/data/list/skill-2.jsonld"}', + ]); // form value }); - cy.get('solid-form-multiple#test3 > button') - .should('have.class', 'class-addbutton'); - cy.get('solid-form-multiple#test3 > div[data-index="test0"] > button') - .should('have.class', 'class-removebutton'); + cy.get('solid-form-multiple#test3 > button').should( + 'have.class', + 'class-addbutton', + ); + cy.get( + 'solid-form-multiple#test3 > div[data-index="test0"] > button', + ).should('have.class', 'class-removebutton'); }); - it('solid-form-multipleselect', () => { cy.get('solid-form-multipleselect') // check data-src - .should('have.attr', 'data-src', '/examples/data/list/user-1-skills.jsonld') - .children().should('have.length', 1); + .should( + 'have.attr', + 'data-src', + '/examples/data/list/user-1-skills.jsonld', + ) + .children() + .should('have.length', 1); cy.get('solid-form-multipleselect') .find('solid-form-dropdown') @@ -153,16 +204,35 @@ describe('multiple widgets', { testIsolation: false }, function () { .should('have.attr', 'name', 'test') .should('have.attr', 'range', '/examples/data/list/skills.jsonld') .should('have.attr', 'data-src', '/examples/data/list/skills.jsonld') - .should('have.attr', 'values', '["/examples/data/list/skill-2.jsonld","/examples/data/list/skill-3.jsonld"]'); - - cy.get('solid-form-multipleselect').then($el => { // Check API - expect((<any>$el[0]).component.value).to.equal('/examples/data/list/user-1-skills.jsonld'); // value attribute - expect((<any>$el[0]).component.getValue()).to.deep.equal([{ "@id": "/examples/data/list/skill-2.jsonld" }, { "@id": "/examples/data/list/skill-3.jsonld" }]); // form value + .should( + 'have.attr', + 'values', + '["/examples/data/list/skill-2.jsonld","/examples/data/list/skill-3.jsonld"]', + ); + + cy.get('solid-form-multipleselect').then($el => { + // Check API + expect((<any>$el[0]).component.value).to.equal( + '/examples/data/list/user-1-skills.jsonld', + ); // value attribute + expect((<any>$el[0]).component.getValue()).to.deep.equal([ + { '@id': '/examples/data/list/skill-2.jsonld' }, + { '@id': '/examples/data/list/skill-3.jsonld' }, + ]); // form value }); - cy.get('solid-form-multipleselect select').select(['CSS', 'Javascript', 'DevOps']); - cy.get('solid-form-multipleselect').then($el => { // Check API - expect((<any>$el[0]).component.getValue()).to.deep.equal([{ "@id": "/examples/data/list/skill-2.jsonld" }, { "@id": "/examples/data/list/skill-3.jsonld" }, { "@id": "/examples/data/list/skill-4.jsonld" }]); // form value + cy.get('solid-form-multipleselect select').select([ + 'CSS', + 'Javascript', + 'DevOps', + ]); + cy.get('solid-form-multipleselect').then($el => { + // Check API + expect((<any>$el[0]).component.getValue()).to.deep.equal([ + { '@id': '/examples/data/list/skill-2.jsonld' }, + { '@id': '/examples/data/list/skill-3.jsonld' }, + { '@id': '/examples/data/list/skill-4.jsonld' }, + ]); // form value }); }); @@ -182,51 +252,79 @@ describe('multiple widgets', { testIsolation: false }, function () { .and('have.attr', 'name', 'test1') .and('have.attr', 'style', 'display: none;') .and('have.attr', 'data-id'); - cy.get('solid-form-multipleselect-autocompletion > div.ss-content > div.ss-list .ss-option').eq(0) + cy.get( + 'solid-form-multipleselect-autocompletion > div.ss-content > div.ss-list .ss-option', + ) + .eq(0) .should('contain', 'CSS'); // select values - cy.get('solid-form-multipleselect-autocompletion .ss-main').filter(":visible").eq(0).click(); - cy.get('solid-form-multipleselect-autocompletion .ss-content.ss-open-below .ss-option').eq(1).click(); - cy.get('solid-form-multipleselect-autocompletion .ss-option').eq(1) + cy.get('solid-form-multipleselect-autocompletion .ss-main') + .filter(':visible') + .eq(0) + .click(); + cy.get( + 'solid-form-multipleselect-autocompletion .ss-content.ss-open-below .ss-option', + ) + .eq(1) + .click(); + cy.get('solid-form-multipleselect-autocompletion .ss-option') + .eq(1) .should('have.class', 'ss-selected'); - cy.get('solid-form-multipleselect-autocompletion .ss-values').eq(1) - .children().should('have.length', 1) + cy.get('solid-form-multipleselect-autocompletion .ss-values') + .eq(1) + .children() + .should('have.length', 1) .should('contain', 'DevOps'); }); it('solid-form-autocompletion-placeholder & search attributes', () => { // attributes for placeholders and text displayed in SlimSelect cy.get('#search-attr') - .find('.ss-placeholder').filter(":visible").contains('Sélectionne une compétence') - .click({force: true}); + .find('.ss-placeholder') + .filter(':visible') + .contains('Sélectionne une compétence') + .click({ force: true }); cy.get('solid-form-multipleselect-autocompletion-placeholder') - .find('.ss-search').children().eq(0) + .find('.ss-search') + .children() + .eq(0) .should('have.attr', 'placeholder', 'Rechercher par clavier') .wait(200) .type('00'); cy.get('#search-attr') - .find('.ss-list').children().contains('Pas de concordance') - }) + .find('.ss-list') + .children() + .contains('Pas de concordance'); + }); it('solid-form-checkboxes', () => { cy.get('solid-form-checkboxes#test1') .find('solid-form-multicheckbox > div[name=test1]') - .children().should('have.length', 8); - cy.get('solid-form-checkboxes#test1 input[type=checkbox]').eq(0) + .children() + .should('have.length', 8); + cy.get('solid-form-checkboxes#test1 input[type=checkbox]') + .eq(0) .should('not.have.attr', 'checked'); - cy.get('solid-form-checkboxes#test1 input[type=checkbox]').eq(1) + cy.get('solid-form-checkboxes#test1 input[type=checkbox]') + .eq(1) .should('have.attr', 'checked'); - cy.get('solid-form-checkboxes#test1 input[type=checkbox]').eq(2) + cy.get('solid-form-checkboxes#test1 input[type=checkbox]') + .eq(2) .should('have.attr', 'checked'); - cy.get('solid-form-checkboxes#test1 input[type=checkbox]').eq(3) + cy.get('solid-form-checkboxes#test1 input[type=checkbox]') + .eq(3) .should('not.have.attr', 'checked'); - cy.get('solid-form-checkboxes#test1 input[type=checkbox]').eq(4) + cy.get('solid-form-checkboxes#test1 input[type=checkbox]') + .eq(4) .should('not.have.attr', 'checked'); - cy.get('solid-form-checkboxes#test1 input[type=checkbox]').eq(5) + cy.get('solid-form-checkboxes#test1 input[type=checkbox]') + .eq(5) .should('not.have.attr', 'checked'); - cy.get('solid-form-checkboxes#test1 input[type=checkbox]').eq(6) + cy.get('solid-form-checkboxes#test1 input[type=checkbox]') + .eq(6) .should('not.have.attr', 'checked'); - cy.get('solid-form-checkboxes#test1 input[type=checkbox]').eq(7) + cy.get('solid-form-checkboxes#test1 input[type=checkbox]') + .eq(7) .should('not.have.attr', 'checked'); // Get value @@ -234,8 +332,9 @@ describe('multiple widgets', { testIsolation: false }, function () { .find('input[value="html"]') .check({ force: true }); - cy.get('solid-form-checkboxes#test2').then($el => { // Check API + cy.get('solid-form-checkboxes#test2').then($el => { + // Check API expect((<any>$el[0]).component.getValue()).to.deep.equal(['html']); // form value }); }); -}) +}); diff --git a/cypress/e2e/e2e/widgets-form.cy.ts b/cypress/e2e/e2e/widgets-form.cy.ts index 7440f7d0..f4c6b145 100644 --- a/cypress/e2e/e2e/widgets-form.cy.ts +++ b/cypress/e2e/e2e/widgets-form.cy.ts @@ -2,12 +2,11 @@ describe('form widgets', { testIsolation: false }, function () { this.beforeAll('visit', () => { cy.clock(Date.UTC(2020, 11, 15), ['Date']); // Define fake date for start-value="today" test - cy.visit('/examples/e2e/widgets-form.html') - }) + cy.visit('/examples/e2e/widgets-form.html'); + }); it('solid-form-text', () => { - cy.get('solid-form-text') - .children().should('have.length', 1); + cy.get('solid-form-text').children().should('have.length', 1); cy.get('solid-form-text') // check attributes .find('input') @@ -15,50 +14,54 @@ describe('form widgets', { testIsolation: false }, function () { .and('have.attr', 'name', 'test1') .and('have.attr', 'value', 'test value 1') .and('have.attr', 'data-holder'); - cy.get('solid-form-text').then($el => { // check API value + cy.get('solid-form-text').then($el => { + // check API value expect((<any>$el[0]).component.getValue()).to.equal('test value 1'); // form value }); cy.get('solid-form-text > input') // type value .clear() .type('new value'); - cy.get('solid-form-text > input') - .and('have.attr', 'value', 'test value 1'); // attr does not change + cy.get('solid-form-text > input').and('have.attr', 'value', 'test value 1'); // attr does not change - cy.get('solid-form-text').then($el => { // Check API + cy.get('solid-form-text').then($el => { + // Check API expect((<any>$el[0]).component['value']).to.equal('test value 1'); // value attribute expect((<any>$el[0]).component.getValue()).to.equal('new value'); // form value }); cy.get('solid-form-text > input') // clear value .clear(); - cy.get('solid-form-text').then($el => { // Check API + cy.get('solid-form-text').then($el => { + // Check API expect((<any>$el[0]).component.getValue()).to.equal(''); // value attribute }); }); it('solid-form-text + label and placeholders', () => { + cy.get('solid-form-text-label').children().should('have.length', 2); cy.get('solid-form-text-label') - .children().should('have.length', 2); - cy.get('solid-form-text-label') - .find('> label').should('contain', 'My label'); + .find('> label') + .should('contain', 'My label'); + cy.get('solid-form-text-placeholder').children().should('have.length', 1); cy.get('solid-form-text-placeholder') - .children().should('have.length', 1); - cy.get('solid-form-text-placeholder') - .find('> input').should('have.attr', 'placeholder', 'My placeholder'); + .find('> input') + .should('have.attr', 'placeholder', 'My placeholder'); cy.get('solid-form-text-label-placeholder') - .children().should('have.length', 2); + .children() + .should('have.length', 2); cy.get('solid-form-text-label-placeholder') - .find('> label').should('contain', 'test1'); + .find('> label') + .should('contain', 'test1'); cy.get('solid-form-text-label-placeholder') - .find('> input').should('have.attr', 'placeholder', 'test1'); + .find('> input') + .should('have.attr', 'placeholder', 'test1'); }); it('solid-form-textarea', () => { - cy.get('solid-form-textarea') - .children().should('have.length', 1); + cy.get('solid-form-textarea').children().should('have.length', 1); cy.get('solid-form-textarea') // check attributes .find('textarea') @@ -66,7 +69,8 @@ describe('form widgets', { testIsolation: false }, function () { .and('have.attr', 'maxlength', '15') .and('have.attr', 'data-holder'); - cy.get('solid-form-textarea').then($el => { // check API value + cy.get('solid-form-textarea').then($el => { + // check API value expect((<any>$el[0]).component.getValue()).to.equal('test value 1'); // form value }); @@ -74,8 +78,8 @@ describe('form widgets', { testIsolation: false }, function () { .clear() .type('new value'); - - cy.get('solid-form-textarea').then($el => { // Check API + cy.get('solid-form-textarea').then($el => { + // Check API expect((<any>$el[0]).component['value']).to.equal('test value 1'); // value attribute expect((<any>$el[0]).component.getValue()).to.equal('new value'); // form value }); @@ -83,16 +87,15 @@ describe('form widgets', { testIsolation: false }, function () { cy.get('solid-form-textarea > textarea') // type value .clear() .type('new value with a maxlength'); - cy.get('solid-form-textarea').then($el => { // Check API + cy.get('solid-form-textarea').then($el => { + // Check API expect((<any>$el[0]).component.getValue()).to.equal('new value with '); // maxlength attribute effect }); - }) + }); it('solid-form-checkbox', () => { - cy.get('solid-form-checkbox') - .children().should('have.length', 1); - cy.get('solid-form-checkbox > label') - .children().should('have.length', 2); + cy.get('solid-form-checkbox').children().should('have.length', 1); + cy.get('solid-form-checkbox > label').children().should('have.length', 2); cy.get('solid-form-checkbox') // check attributes .find('input') @@ -100,30 +103,27 @@ describe('form widgets', { testIsolation: false }, function () { .and('have.attr', 'type', 'checkbox') .and('have.attr', 'data-holder', '') .and('have.attr', 'checked'); - cy.get('solid-form-checkbox') - .find('div') - .contains('test1'); - + cy.get('solid-form-checkbox').find('div').contains('test1'); - cy.get('solid-form-checkbox').then($el => { // Check API + cy.get('solid-form-checkbox').then($el => { + // Check API expect((<any>$el[0]).component['value']).to.equal('true'); // value attribute expect((<any>$el[0]).component.getValue()).to.equal(true); // form value }); - cy.get('solid-form-checkbox') // Change value - .find('input').click(); - + .find('input') + .click(); - cy.get('solid-form-checkbox').then($el => { // Check API + cy.get('solid-form-checkbox').then($el => { + // Check API expect((<any>$el[0]).component['value']).to.equal('true'); // value attribute expect((<any>$el[0]).component.getValue()).to.equal(false); // form value }); - }) + }); it('solid-form-date', () => { - cy.get('solid-form-date#test1') - .children().should('have.length', 1); + cy.get('solid-form-date#test1').children().should('have.length', 1); // check attributes cy.get('solid-form-date#test1') .find('input') @@ -132,11 +132,12 @@ describe('form widgets', { testIsolation: false }, function () { .and('have.attr', 'value', '2020-05-21') .and('have.attr', 'data-holder'); // type value - cy.get('solid-form-date#test1 > input') - .clear() - .type('2020-12-31'); - cy.get('solid-form-date#test1 > input') - .and('have.attr', 'value', '2020-05-21'); // attr does not change + cy.get('solid-form-date#test1 > input').clear().type('2020-12-31'); + cy.get('solid-form-date#test1 > input').and( + 'have.attr', + 'value', + '2020-05-21', + ); // attr does not change // Check API cy.get('solid-form-date#test1').then($el => { @@ -147,14 +148,11 @@ describe('form widgets', { testIsolation: false }, function () { cy.get('solid-form-date#test2') .find('input') .and('have.attr', 'value', '2020-05-21'); - cy.get('solid-form-date#test3') - .find('input') - .and('have.attr', 'value', ''); - }) + cy.get('solid-form-date#test3').find('input').and('have.attr', 'value', ''); + }); it('solid-form-number', () => { - cy.get('solid-form-number') - .children().should('have.length', 1); + cy.get('solid-form-number').children().should('have.length', 1); cy.get('solid-form-number') // check attributes .find('input') @@ -165,36 +163,35 @@ describe('form widgets', { testIsolation: false }, function () { .and('have.attr', 'max', '7') .and('have.attr', 'data-holder'); - cy.get('solid-form-number').then($el => { // check API value + cy.get('solid-form-number').then($el => { + // check API value expect((<any>$el[0]).component.getValue()).to.equal(5); // form value }); cy.get('solid-form-number > input') // type value .clear() .type('8'); - cy.get('solid-form-number > input') - .and('have.attr', 'value', '5'); // attr does not change - + cy.get('solid-form-number > input').and('have.attr', 'value', '5'); // attr does not change - cy.get('solid-form-number').then($el => { // Check API + cy.get('solid-form-number').then($el => { + // Check API expect((<any>$el[0]).component['value']).to.equal('5'); // value attribute expect((<any>$el[0]).component.getValue()).to.equal(8); // form value }); - // step attribute + // step attribute cy.get('solid-form-number > input') // type value .clear() .type('{upArrow}{upArrow}{upArrow}'); - cy.get('solid-form-number').then($el => { // check API value + cy.get('solid-form-number').then($el => { + // check API value expect((<any>$el[0]).component.getValue()).to.equal(6); // form value }); - }); it('solid-form-email', () => { - cy.get('solid-form-email') - .children().should('have.length', 1); + cy.get('solid-form-email').children().should('have.length', 1); cy.get('solid-form-email') // check attributes .find('input') @@ -203,26 +200,29 @@ describe('form widgets', { testIsolation: false }, function () { .and('have.attr', 'value', 'test@test.com') .and('have.attr', 'data-holder'); - cy.get('solid-form-email').then($el => { // check API value + cy.get('solid-form-email').then($el => { + // check API value expect((<any>$el[0]).component.getValue()).to.equal('test@test.com'); // form value }); cy.get('solid-form-email > input') // type value .clear() .type('new@example.com'); - cy.get('solid-form-email > input') - .and('have.attr', 'value', 'test@test.com'); // attr does not change - - - cy.get('solid-form-email').then($el => { // Check API + cy.get('solid-form-email > input').and( + 'have.attr', + 'value', + 'test@test.com', + ); // attr does not change + + cy.get('solid-form-email').then($el => { + // Check API expect((<any>$el[0]).component['value']).to.equal('test@test.com'); // value attribute expect((<any>$el[0]).component.getValue()).to.equal('new@example.com'); // form value }); }); it('solid-form-hidden', () => { - cy.get('solid-form-hidden') - .children().should('have.length', 1); + cy.get('solid-form-hidden').children().should('have.length', 1); cy.get('solid-form-hidden') // check attributes .find('input') @@ -231,113 +231,162 @@ describe('form widgets', { testIsolation: false }, function () { .and('have.attr', 'value', 'test value 1') .and('have.attr', 'data-holder'); - cy.get('solid-form-hidden').then($el => { // check API value + cy.get('solid-form-hidden').then($el => { + // check API value expect((<any>$el[0]).component.getValue()).to.equal('test value 1'); // form value }); cy.get('solid-form-hidden > input') // type value .invoke('attr', 'value', 'new value'); - cy.get('solid-form-hidden').then($el => { // Check API + cy.get('solid-form-hidden').then($el => { + // Check API expect((<any>$el[0]).component['value']).to.equal('test value 1'); // value attribute expect((<any>$el[0]).component.getValue()).to.equal('new value'); // form value }); - }) + }); it('solid-form-dropdown', () => { // With no initial value cy.get('solid-form-dropdown#test1') .should('have.attr', 'data-src', '/examples/data/list/skills.jsonld') - .children().should('have.length', 1); + .children() + .should('have.length', 1); cy.get('solid-form-dropdown#test1') // check attributes .find('select') .and('have.attr', 'name', 'test1') .and('have.attr', 'data-holder', '') - .children().and('have.length', 9); + .children() + .and('have.length', 9); - cy.get('solid-form-dropdown#test1 > select > option').eq(0) // check options + cy.get('solid-form-dropdown#test1 > select > option') + .eq(0) // check options .should('have.attr', 'value', '') .contains('-'); - cy.get('solid-form-dropdown#test1 > select > option').eq(1) - .should('have.attr', 'value', '{"@id": "/examples/data/list/skill-1.jsonld"}') + cy.get('solid-form-dropdown#test1 > select > option') + .eq(1) + .should( + 'have.attr', + 'value', + '{"@id": "/examples/data/list/skill-1.jsonld"}', + ) .contains('HTML'); - cy.get('solid-form-dropdown#test1').then($el => { // Check API value + cy.get('solid-form-dropdown#test1').then($el => { + // Check API value expect((<any>$el[0]).component.getValue()).to.equal(''); // form value }); - cy.get('solid-form-dropdown#test1 > select').select('CSS').should('have.value', '{"@id": "/examples/data/list/skill-2.jsonld"}'); // test change value + cy.get('solid-form-dropdown#test1 > select') + .select('CSS') + .should('have.value', '{"@id": "/examples/data/list/skill-2.jsonld"}'); // test change value - cy.get('solid-form-dropdown#test1').then($el => { // Check API + cy.get('solid-form-dropdown#test1').then($el => { + // Check API expect((<any>$el[0]).component['value']).to.equal(''); // value attribute - expect((<any>$el[0]).component.getValue()).to.equal('{"@id": "/examples/data/list/skill-2.jsonld"}'); // form value + expect((<any>$el[0]).component.getValue()).to.equal( + '{"@id": "/examples/data/list/skill-2.jsonld"}', + ); // form value expect((<any>$el[0]).component.context).to.be.not.empty; // check storeMixin properties expect((<any>$el[0]).component.resourceId).to.be.not.empty; // check storeMixin properties }); // With initial value - cy.get('solid-form-dropdown#test2 > select').should('have.value', '{"@id": "/examples/data/list/skill-2.jsonld"}'); + cy.get('solid-form-dropdown#test2 > select').should( + 'have.value', + '{"@id": "/examples/data/list/skill-2.jsonld"}', + ); cy.get('solid-form-dropdown#test2').then($el => { - expect((<any>$el[0]).component['value']).to.equal('/examples/data/list/skill-2.jsonld'); // value attribute - expect((<any>$el[0]).component.getValue()).to.equal('{"@id": "/examples/data/list/skill-2.jsonld"}'); // form value + expect((<any>$el[0]).component['value']).to.equal( + '/examples/data/list/skill-2.jsonld', + ); // value attribute + expect((<any>$el[0]).component.getValue()).to.equal( + '{"@id": "/examples/data/list/skill-2.jsonld"}', + ); // form value }); // With optionLabel - cy.get('solid-form-dropdown#test3 > select > option').eq(1) - .should('have.attr', 'value', '{"@id": "/examples/data/list/skill-1.jsonld"}') + cy.get('solid-form-dropdown#test3 > select > option') + .eq(1) + .should( + 'have.attr', + 'value', + '{"@id": "/examples/data/list/skill-1.jsonld"}', + ) .contains('/examples/data/list/skill-1.jsonld'); // With multiple cy.get('solid-form-dropdown#test4 > select') .should('have.attr', 'multiple', 'multiple') - .children().should('have.length', 8); + .children() + .should('have.length', 8); cy.get('solid-form-dropdown#test4').then($el => { - expect((<any>$el[0]).component.getValue()).to.deep.equal([{ '@id': '/examples/data/list/skill-1.jsonld' }, { '@id': '/examples/data/list/skill-3.jsonld' }]); // form value + expect((<any>$el[0]).component.getValue()).to.deep.equal([ + { '@id': '/examples/data/list/skill-1.jsonld' }, + { '@id': '/examples/data/list/skill-3.jsonld' }, + ]); // form value }); - cy.get('solid-form-dropdown#test4 > select').select(['CSS', 'Javascript']) // change value + cy.get('solid-form-dropdown#test4 > select').select(['CSS', 'Javascript']); // change value cy.get('solid-form-dropdown#test4').then($el => { - expect((<any>$el[0]).component.getValue()).to.deep.equal([{ '@id': '/examples/data/list/skill-2.jsonld' }, { '@id': '/examples/data/list/skill-3.jsonld' }]); // form value + expect((<any>$el[0]).component.getValue()).to.deep.equal([ + { '@id': '/examples/data/list/skill-2.jsonld' }, + { '@id': '/examples/data/list/skill-3.jsonld' }, + ]); // form value }); // With order-desc - cy.get('solid-form-dropdown#test5 > select > option').eq(1) + cy.get('solid-form-dropdown#test5 > select > option') + .eq(1) .should('contain', 'Python'); - cy.get('solid-form-dropdown#test5 > select > option').eq(2) + cy.get('solid-form-dropdown#test5 > select > option') + .eq(2) .should('contain', 'PHP'); - cy.get('solid-form-dropdown#test5 > select > option').eq(3) + cy.get('solid-form-dropdown#test5 > select > option') + .eq(3) .should('contain', 'Node'); - cy.get('solid-form-dropdown#test5 > select > option').eq(4) + cy.get('solid-form-dropdown#test5 > select > option') + .eq(4) .should('contain', 'Javascript'); - cy.get('solid-form-dropdown#test5 > select > option').eq(5) + cy.get('solid-form-dropdown#test5 > select > option') + .eq(5) .should('contain', 'HTML'); - cy.get('solid-form-dropdown#test5 > select > option').eq(6) + cy.get('solid-form-dropdown#test5 > select > option') + .eq(6) .should('contain', 'Git'); - cy.get('solid-form-dropdown#test5 > select > option').eq(7) + cy.get('solid-form-dropdown#test5 > select > option') + .eq(7) .should('contain', 'DevOps'); - cy.get('solid-form-dropdown#test5 > select > option').eq(8) + cy.get('solid-form-dropdown#test5 > select > option') + .eq(8) .should('contain', 'CSS'); // With federation - cy.get('solid-form-dropdown#test6 > select > option[value="{\\"@id\\": \\"/examples/data/federation/circles-1.jsonld\\"}"]') - .should('contain', 'Circle from server 1'); - cy.get('solid-form-dropdown#test6 > select > option[value="{\\"@id\\": \\"/examples/data/federation/circles-2.jsonld\\"}"]') - .should('contain', 'Another circle from server 1'); - cy.get('solid-form-dropdown#test6 > select > option[value="{\\"@id\\": \\"/examples/data/federation/circles-3.jsonld\\"}"]') - .should('contain', 'Circle from server 2'); - cy.get('solid-form-dropdown#test6 > select > option[value="{\\"@id\\": \\"/examples/data/federation/circles-4.jsonld\\"}"]') - .should('contain', 'Another circle from server 2'); + cy.get( + 'solid-form-dropdown#test6 > select > option[value="{\\"@id\\": \\"/examples/data/federation/circles-1.jsonld\\"}"]', + ).should('contain', 'Circle from server 1'); + cy.get( + 'solid-form-dropdown#test6 > select > option[value="{\\"@id\\": \\"/examples/data/federation/circles-2.jsonld\\"}"]', + ).should('contain', 'Another circle from server 1'); + cy.get( + 'solid-form-dropdown#test6 > select > option[value="{\\"@id\\": \\"/examples/data/federation/circles-3.jsonld\\"}"]', + ).should('contain', 'Circle from server 2'); + cy.get( + 'solid-form-dropdown#test6 > select > option[value="{\\"@id\\": \\"/examples/data/federation/circles-4.jsonld\\"}"]', + ).should('contain', 'Another circle from server 2'); // With enumeration in range cy.get('solid-form-dropdown#test7 > select') .should('have.value', 'option1') - .children().should('have.length', 5) + .children() + .should('have.length', 5) .eq(2) .should('have.attr', 'value', 'option2') .should('contain', 'option2'); cy.get('solid-form-dropdown#test8 > select') - .children().should('have.length', 4) + .children() + .should('have.length', 4) .eq(1) .should('have.attr', 'value', '1') .should('contain', 'option a'); @@ -347,7 +396,8 @@ describe('form widgets', { testIsolation: false }, function () { .children() .should('have.length', 8); cy.get('solid-form-dropdown-autocompletion-placeholder > div') - .find('div.ss-search').children() + .find('div.ss-search') + .children() .eq(0) .should('have.attr', 'placeholder', 'Skills :'); cy.get('solid-form-dropdown-autocompletion-placeholder > div') @@ -359,61 +409,92 @@ describe('form widgets', { testIsolation: false }, function () { // With option-value cy.get('solid-form-dropdown#test10 > select') - .children().eq(2) + .children() + .eq(2) .should('have.attr', 'value', 'CSS') .should('contain', 'CSS'); cy.get('solid-form-dropdown#test11 > select') - .children().eq(2) - .should('have.attr', 'value', '{"@id": "/examples/data/list/profile-2.jsonld"}'); + .children() + .eq(2) + .should( + 'have.attr', + 'value', + '{"@id": "/examples/data/list/profile-2.jsonld"}', + ); cy.get('solid-form-dropdown#test12 > select') - .children().eq(2) - .should('have.attr', 'value', '{"@id": "/examples/data/list/profile-2.jsonld"}'); - }) + .children() + .eq(2) + .should( + 'have.attr', + 'value', + '{"@id": "/examples/data/list/profile-2.jsonld"}', + ); + }); it('solid-form-radio', () => { // With no initial value cy.get('solid-form-radio#test1') .should('have.attr', 'data-src', '/examples/data/list/skills.jsonld') - .children().should('have.length', 1); + .children() + .should('have.length', 1); cy.get('solid-form-radio#test1') // check attributes .find('> div') .and('have.attr', 'name', 'test1') - .children().and('have.length', 8); + .children() + .and('have.length', 8); - cy.get('solid-form-radio#test1 > div > label').eq(0) // check options + cy.get('solid-form-radio#test1 > div > label') + .eq(0) // check options .contains('HTML') .parent() .find('input') .should('have.attr', 'type', 'radio') - .should('have.attr', 'value', '{"@id": "/examples/data/list/skill-1.jsonld"}'); - - cy.get('solid-form-radio#test1').then($el => { // Check API value + .should( + 'have.attr', + 'value', + '{"@id": "/examples/data/list/skill-1.jsonld"}', + ); + + cy.get('solid-form-radio#test1').then($el => { + // Check API value expect((<any>$el[0]).component.getValue()).to.equal(''); // form value }); cy.get('solid-form-radio#test1 > div > label').eq(1).click(); // test change value - cy.get('solid-form-radio#test1').then($el => { // Check API + cy.get('solid-form-radio#test1').then($el => { + // Check API expect((<any>$el[0]).component['value']).to.equal(''); // value attribute - expect((<any>$el[0]).component.getValue()).to.equal('{"@id": "/examples/data/list/skill-2.jsonld"}'); // form value + expect((<any>$el[0]).component.getValue()).to.equal( + '{"@id": "/examples/data/list/skill-2.jsonld"}', + ); // form value expect((<any>$el[0]).component.context).to.be.not.empty; // check storeMixin properties expect((<any>$el[0]).component.resourceId).to.be.not.empty; // check storeMixin properties }); // With initial value - cy.get('solid-form-radio#test2 label').eq(2).find('input').should('have.attr', 'checked', 'checked'); + cy.get('solid-form-radio#test2 label') + .eq(2) + .find('input') + .should('have.attr', 'checked', 'checked'); cy.get('solid-form-radio#test2').then($el => { - expect((<any>$el[0]).component['value']).to.equal('/examples/data/list/skill-3.jsonld'); // value attribute - expect((<any>$el[0]).component.getValue()).to.equal('{"@id": "/examples/data/list/skill-3.jsonld"}'); // form value + expect((<any>$el[0]).component['value']).to.equal( + '/examples/data/list/skill-3.jsonld', + ); // value attribute + expect((<any>$el[0]).component.getValue()).to.equal( + '{"@id": "/examples/data/list/skill-3.jsonld"}', + ); // form value }); cy.get('solid-form-radio#test3') .find('> div') .and('have.attr', 'name', 'test3') - .children().and('have.length', '3'); + .children() + .and('have.length', '3'); - cy.get('solid-form-radio#test3 > div > label').eq(0) + cy.get('solid-form-radio#test3 > div > label') + .eq(0) .contains('option1') .parent() .find('input') @@ -422,54 +503,66 @@ describe('form widgets', { testIsolation: false }, function () { // Test click on multiple radio cy.get('solid-form-radio#test3 input[type=radio][value="option1"]') - .check().should('be.checked'); - cy.get('solid-form-radio#test3 input[type=radio][value="option2"]') - .should('not.be.checked'); - cy.get('solid-form-radio#test3 input[type=radio][value="option3"]') - .should('not.be.checked'); + .check() + .should('be.checked'); + cy.get('solid-form-radio#test3 input[type=radio][value="option2"]').should( + 'not.be.checked', + ); + cy.get('solid-form-radio#test3 input[type=radio][value="option3"]').should( + 'not.be.checked', + ); cy.get('solid-form-radio#test3 input[type=radio][value="option3"]') - .check().should('be.checked'); - cy.get('solid-form-radio#test3 input[type=radio][value="option1"]') - .should('not.be.checked'); - cy.get('solid-form-radio#test3 input[type=radio][value="option2"]') - .should('not.be.checked'); + .check() + .should('be.checked'); + cy.get('solid-form-radio#test3 input[type=radio][value="option1"]').should( + 'not.be.checked', + ); + cy.get('solid-form-radio#test3 input[type=radio][value="option2"]').should( + 'not.be.checked', + ); cy.get('solid-form-radio#test4') .find('> div') .and('have.attr', 'name', 'test4') - .children().and('have.length', '4') + .children() + .and('have.length', '4'); - cy.get('solid-form-radio#test4 > div > label').eq(0) + cy.get('solid-form-radio#test4 > div > label') + .eq(0) .contains('option1') .parent() .find('input') .should('have.attr', 'type', 'radio') .should('have.attr', 'value', 'a'); - }) + }); it('solid-form-checkboxes', () => { cy.get('#test-checkboxes') - .find('label:nth-child(-2n + 6)').click({ multiple: true }) + .find('label:nth-child(-2n + 6)') + .click({ multiple: true }); cy.get('#test-checkboxes').then(async ($el: any) => { const values = await $el[0].component.getValue(); expect(values).to.deep.equal([ - { "@id": "/examples/data/list/skill-2.jsonld" }, - { "@id": "/examples/data/list/skill-4.jsonld" }, - { "@id": "/examples/data/list/skill-6.jsonld" }, + { '@id': '/examples/data/list/skill-2.jsonld' }, + { '@id': '/examples/data/list/skill-4.jsonld' }, + { '@id': '/examples/data/list/skill-6.jsonld' }, ]); }); - }) + }); it('solid-form-rangenumber', () => { cy.get('solid-form-rangenumber[name=test1]') - .children().should('have.length', 2); + .children() + .should('have.length', 2); - cy.get('solid-form-rangenumber > input').eq(0) + cy.get('solid-form-rangenumber > input') + .eq(0) .should('have.attr', 'data-holder', '') .and('have.attr', 'type', 'number') .and('have.attr', 'name', 'test1-start'); - cy.get('solid-form-rangenumber > input').eq(1) + cy.get('solid-form-rangenumber > input') + .eq(1) .should('have.attr', 'data-holder', '') .and('have.attr', 'type', 'number') .and('have.attr', 'name', 'test1-end'); @@ -488,21 +581,26 @@ describe('form widgets', { testIsolation: false }, function () { }); // Addition start-value-[field] and end-value-[field] attributes - cy.get('solid-form-rangenumber[name=test2] > input').eq(0) - .should('have.attr', 'value', '2') - cy.get('solid-form-rangenumber[name=test2] > input').eq(1) - .should('have.attr', 'value', '10') + cy.get('solid-form-rangenumber[name=test2] > input') + .eq(0) + .should('have.attr', 'value', '2'); + cy.get('solid-form-rangenumber[name=test2] > input') + .eq(1) + .should('have.attr', 'value', '10'); }); it('solid-form-rangedate', () => { cy.get('solid-form-rangedate[name=test1]') - .children().should('have.length', 2); + .children() + .should('have.length', 2); - cy.get('solid-form-rangedate > input').eq(0) + cy.get('solid-form-rangedate > input') + .eq(0) .should('have.attr', 'data-holder', '') .and('have.attr', 'type', 'date') .and('have.attr', 'name', 'test1-start'); - cy.get('solid-form-rangedate > input').eq(1) + cy.get('solid-form-rangedate > input') + .eq(1) .should('have.attr', 'data-holder', '') .and('have.attr', 'type', 'date') .and('have.attr', 'name', 'test1-end'); @@ -513,50 +611,69 @@ describe('form widgets', { testIsolation: false }, function () { cy.get('solid-form-rangedate > input').eq(0).type('2020-02-12'); cy.get('solid-form-rangedate').then($el => { - expect((<any>$el[0]).component.getValue()).to.deep.equal(['2020-02-12', '']); // form value + expect((<any>$el[0]).component.getValue()).to.deep.equal([ + '2020-02-12', + '', + ]); // form value }); cy.get('solid-form-rangedate > input').eq(1).type('2020-05-24'); cy.get('solid-form-rangedate').then($el => { - expect((<any>$el[0]).component.getValue()).to.deep.equal(['2020-02-12', '2020-05-24']); // form value + expect((<any>$el[0]).component.getValue()).to.deep.equal([ + '2020-02-12', + '2020-05-24', + ]); // form value }); // Addition start-value-[field] and end-value-[field] attributes - cy.get('solid-form-rangedate[name=test2] > input').eq(0) - .should('have.attr', 'value', '2020-12-15') - cy.get('solid-form-rangedate[name=test2] > input').eq(1) - .should('have.attr', 'value', '2222-12-22') + cy.get('solid-form-rangedate[name=test2] > input') + .eq(0) + .should('have.attr', 'value', '2020-12-15'); + cy.get('solid-form-rangedate[name=test2] > input') + .eq(1) + .should('have.attr', 'value', '2222-12-22'); }); it('solid-form-color', () => { - cy.get('solid-form-color') - .children().should('have.length', 1) + cy.get('solid-form-color').children().should('have.length', 1); - cy.get('solid-form-color > input') - .should('have.attr', 'type', 'color') + cy.get('solid-form-color > input').should('have.attr', 'type', 'color'); }); it('solid-form-text-labellast', () => { - cy.get('solid-form-text-labellast').children() - .should('have.length', 2); - cy.get('solid-form-text-labellast').find('label').last() + cy.get('solid-form-text-labellast').children().should('have.length', 2); + cy.get('solid-form-text-labellast') + .find('label') + .last() .should('contain', 'test labellast'); }); it('solid-form-dropdown-addable', () => { // Without addable-data-src provided cy.get('solid-form-dropdown-addable#test1') - .children().should('have.length', 2); - cy.get('solid-form-dropdown-addable#test1 > solid-form') - .should('have.attr', 'data-src', '/examples/data/list/skills.jsonld'); + .children() + .should('have.length', 2); + cy.get('solid-form-dropdown-addable#test1 > solid-form').should( + 'have.attr', + 'data-src', + '/examples/data/list/skills.jsonld', + ); cy.get('solid-form-dropdown-addable#test1 > solid-form > form') - .children().should('have.length', 3) - cy.get('solid-form-dropdown-addable#test1 > solid-form > form > solid-form-label-text').eq(0) - .should('have.attr', 'name', 'name') - cy.get('solid-form-dropdown-addable#test1 > solid-form > form > solid-form-label-text').eq(1) - .should('have.attr', 'name', 'order') - cy.get('solid-form-dropdown-addable#test1 > solid-form > form > div > input') - .should('have.attr', 'type', 'submit') + .children() + .should('have.length', 3); + cy.get( + 'solid-form-dropdown-addable#test1 > solid-form > form > solid-form-label-text', + ) + .eq(0) + .should('have.attr', 'name', 'name'); + cy.get( + 'solid-form-dropdown-addable#test1 > solid-form > form > solid-form-label-text', + ) + .eq(1) + .should('have.attr', 'name', 'order'); + cy.get( + 'solid-form-dropdown-addable#test1 > solid-form > form > div > input', + ).should('have.attr', 'type', 'submit'); // With addable-data-src provided @@ -566,52 +683,73 @@ describe('form widgets', { testIsolation: false }, function () { .and('have.attr', 'fields', 'name, username, age') .and('have.attr', 'widget-name', 'solid-form-text-placeholder-label') .and('have.attr', 'placeholder-name', 'Enter your name') - .and('have.attr', 'submit-button', 'Send data') + .and('have.attr', 'submit-button', 'Send data'); cy.get('solid-form-dropdown-addable#test2 > solid-form > form') - .children().should('have.length', 4) - // Verify attributes and values in tags created by widget - cy.get('solid-form-dropdown-addable#test2 > solid-form > form > solid-form-text-placeholder-label') + .children() + .should('have.length', 4); + // Verify attributes and values in tags created by widget + cy.get( + 'solid-form-dropdown-addable#test2 > solid-form > form > solid-form-text-placeholder-label', + ) .should('have.attr', 'name', 'name') - .and('have.attr', 'placeholder', 'Enter your name') - cy.get('solid-form-dropdown-addable#test2 > solid-form > form > solid-form-text-placeholder-label') - .find('label').should('contain', 'name') - cy.get('solid-form-dropdown-addable#test2 > solid-form > form > solid-form-text-placeholder-label') - .find('input').should('have.attr', 'placeholder', 'Enter your name') - - cy.get('solid-form-dropdown-addable#test2 > solid-form > form > solid-form-label-text').eq(0) - .should('have.attr', 'name', 'username') - cy.get('solid-form-dropdown-addable#test2 > solid-form > form > solid-form-label-text').eq(1) - .should('have.attr', 'name', 'age') - cy.get('solid-form-dropdown-addable#test2 > solid-form > form > div > input') + .and('have.attr', 'placeholder', 'Enter your name'); + cy.get( + 'solid-form-dropdown-addable#test2 > solid-form > form > solid-form-text-placeholder-label', + ) + .find('label') + .should('contain', 'name'); + cy.get( + 'solid-form-dropdown-addable#test2 > solid-form > form > solid-form-text-placeholder-label', + ) + .find('input') + .should('have.attr', 'placeholder', 'Enter your name'); + + cy.get( + 'solid-form-dropdown-addable#test2 > solid-form > form > solid-form-label-text', + ) + .eq(0) + .should('have.attr', 'name', 'username'); + cy.get( + 'solid-form-dropdown-addable#test2 > solid-form > form > solid-form-label-text', + ) + .eq(1) + .should('have.attr', 'name', 'age'); + cy.get( + 'solid-form-dropdown-addable#test2 > solid-form > form > div > input', + ) .should('have.attr', 'type', 'submit') - .and('have.attr', 'value', 'Send data') + .and('have.attr', 'value', 'Send data'); }); it('solid-form-password', () => { + cy.get('solid-form-label-password').children().should('have.length', 2); cy.get('solid-form-label-password') - .children().should('have.length', 2); - cy.get('solid-form-label-password') - .children().eq(0).should('contain', 'password'); + .children() + .eq(0) + .should('contain', 'password'); cy.get('solid-form-label-password > input') .should('have.attr', 'type', 'password') .and('have.value', 'password123'); }); it('solid-form-time', () => { + cy.get('solid-form-label-time#time1').children().should('have.length', 2); cy.get('solid-form-label-time#time1') - .children().should('have.length', 2); - cy.get('solid-form-label-time#time1') - .children().eq(0).should('contain', 'time'); + .children() + .eq(0) + .should('contain', 'time'); cy.get('solid-form-label-time#time1 > input') .should('have.attr', 'type', 'time') .and('have.value', '15:15'); cy.get('solid-form-label-time#time2') - .children().eq(0).should('contain', 'start time'); + .children() + .eq(0) + .should('contain', 'start time'); cy.get('solid-form-label-time#time2 > input') .should('have.attr', 'type', 'time') - .and('have.attr', 'min', "12:00") - .and('have.attr', 'max', "14:00") - .and('have.attr', 'step', "3600"); + .and('have.attr', 'min', '12:00') + .and('have.attr', 'max', '14:00') + .and('have.attr', 'step', '3600'); }); -}) +}); diff --git a/cypress/e2e/e2e/widgets-sets.cy.ts b/cypress/e2e/e2e/widgets-sets.cy.ts index cf352462..00cc7f4c 100644 --- a/cypress/e2e/e2e/widgets-sets.cy.ts +++ b/cypress/e2e/e2e/widgets-sets.cy.ts @@ -1,26 +1,19 @@ -describe('set widget', function() { +describe('set widget', function () { this.beforeEach('visit', () => { - cy.visit('/examples/e2e/widgets-sets.html') - }) + cy.visit('/examples/e2e/widgets-sets.html'); + }); it('solid-set-default', () => { - cy.get('solid-set-default') - .children().should('have.length', 0); - }) + cy.get('solid-set-default').children().should('have.length', 0); + }); it('solid-set-div', () => { - cy.get('solid-set-div') - .children().should('have.length', 1); - cy.get('solid-set-div') - .find('div') - .should('have.attr', 'data-content', ''); - }) - + cy.get('solid-set-div').children().should('have.length', 1); + cy.get('solid-set-div').find('div').should('have.attr', 'data-content', ''); + }); + it('solid-set-ul', () => { - cy.get('solid-set-ul') - .children().should('have.length', 1); - cy.get('solid-set-ul') - .find('ul') - .should('have.attr', 'data-content', ''); - }) -}) + cy.get('solid-set-ul').children().should('have.length', 1); + cy.get('solid-set-ul').find('ul').should('have.attr', 'data-content', ''); + }); +}); diff --git a/cypress/e2e/sleep.ts b/cypress/e2e/sleep.ts index c3f3d43f..4c58c343 100644 --- a/cypress/e2e/sleep.ts +++ b/cypress/e2e/sleep.ts @@ -1,3 +1,3 @@ export default function sleep(time = 0) { - return new Promise(resolve => setTimeout(resolve, time)) + return new Promise(resolve => setTimeout(resolve, time)); } diff --git a/cypress/e2e/unit/ComponentFactory.cy.ts b/cypress/e2e/unit/ComponentFactory.cy.ts index 9d44e782..9e6ed6a1 100644 --- a/cypress/e2e/unit/ComponentFactory.cy.ts +++ b/cypress/e2e/unit/ComponentFactory.cy.ts @@ -67,7 +67,7 @@ const Component = { myAttribute: { type: String, default: 'awesome', - callback: function() { + callback: function () { this.change = true; }, }, @@ -112,7 +112,7 @@ const Component = { }, }; -describe('Component factory', function() { +describe('Component factory', function () { it('expose html element', () => { const ComponentConstructor = ComponentFactory.build(Component); const component = new ComponentConstructor(document.createElement('p')); diff --git a/cypress/e2e/unit/Compositor.cy.ts b/cypress/e2e/unit/Compositor.cy.ts index 552335eb..7e9c1c3b 100644 --- a/cypress/e2e/unit/Compositor.cy.ts +++ b/cypress/e2e/unit/Compositor.cy.ts @@ -92,7 +92,7 @@ const component = { }, }; -describe('Mixin Compositor', function() { +describe('Mixin Compositor', function () { it('merge mixin', () => { const result = Compositor.mergeMixin(component); expect(result.length).eq(2); diff --git a/cypress/e2e/unit/helpers.cy.ts b/cypress/e2e/unit/helpers.cy.ts index 3dd5784c..3082859e 100644 --- a/cypress/e2e/unit/helpers.cy.ts +++ b/cypress/e2e/unit/helpers.cy.ts @@ -11,7 +11,7 @@ import { /** * uniqID */ -describe('uniqID', function() { +describe('uniqID', function () { it('returns an id', () => { let test = uniqID(); expect(test).to.match(/[_].{10}/g); @@ -30,7 +30,7 @@ describe('uniqID', function() { /** * stringToDom */ -describe('stringToDom', function() { +describe('stringToDom', function () { it('returns a fragment', () => { const fragment = stringToDom('<h1>Test element</h1>'); expect(fragment.constructor.name).to.eq('DocumentFragment'); @@ -54,7 +54,7 @@ describe('stringToDom', function() { /** * setDeepProperty */ -describe('setDeepProperty', function() { +describe('setDeepProperty', function () { it('set properties', () => { const object = { name: 'test', @@ -91,7 +91,7 @@ describe('setDeepProperty', function() { /** * parseFieldsString */ -describe('parseFieldsString', function() { +describe('parseFieldsString', function () { it('returns first level of fields', () => { const fields = 'field1, field2(field3,field4, field5( field6, field7) ), field8,field9'; @@ -108,7 +108,7 @@ describe('parseFieldsString', function() { /** * findClosingBracketMatchIndex */ -describe('findClosingBracketMatchIndex', function() { +describe('findClosingBracketMatchIndex', function () { it('throw error', () => { const fields = 'field1, field2(field3,field4, field5( field6, field7) ), field8,field9'; @@ -140,7 +140,7 @@ describe('findClosingBracketMatchIndex', function() { /** * evalTemplateString */ -describe('evalTemplateString', function() { +describe('evalTemplateString', function () { it('render template with values', async () => { const values = { val1: 'test 1', @@ -177,9 +177,7 @@ describe('evalTemplateString', function() { </div> `; const promise = new Cypress.Promise((resolve, reject) => { - evalTemplateString(template, values) - .then(resolve) - .catch(reject); + evalTemplateString(template, values).then(resolve).catch(reject); }); promise.finally(() => { expect(promise.isRejected).to.be.true; @@ -265,7 +263,7 @@ describe('evalTemplateString', function() { // } // ] // }; - + // const newValue = transformArrayToContainer(value); // expect(newValue).to.deep.equal({ // "@id": "myresource", @@ -296,27 +294,27 @@ describe('evalTemplateString', function() { // }) // }) // }) -import sleep from '../sleep' -describe('AsyncIterableBuilder', () => { +import sleep from '../sleep'; +describe('AsyncIterableBuilder', () => { it('create an asyncIterable', async () => { - const { iterable, next } = new AsyncIterableBuilder<number>() - next(1) - next(2) - const values: number[] = [] - let done = false - ;(async () => { + const { iterable, next } = new AsyncIterableBuilder<number>(); + next(1); + next(2); + const values: number[] = []; + let done = false; + (async () => { for await (const number of iterable) { - values.push(number) + values.push(number); } - done = true - })() - await sleep() - expect(values).to.deep.eq([1, 2]) - expect(done).to.be.false - next(3) - next(4, true) - await sleep() - expect(values).to.deep.eq([1, 2, 3, 4]) - expect(done).to.be.true - }) -}) \ No newline at end of file + done = true; + })(); + await sleep(); + expect(values).to.deep.eq([1, 2]); + expect(done).to.be.false; + next(3); + next(4, true); + await sleep(); + expect(values).to.deep.eq([1, 2, 3, 4]); + expect(done).to.be.true; + }); +}); diff --git a/cypress/e2e/unit/store.cy.ts b/cypress/e2e/unit/store.cy.ts index 6957f79c..dae5295e 100644 --- a/cypress/e2e/unit/store.cy.ts +++ b/cypress/e2e/unit/store.cy.ts @@ -10,23 +10,25 @@ export const base_context = { acl: 'http://www.w3.org/ns/auth/acl#', permissions: 'acl:accessControl', mode: 'acl:mode', - geo: "http://www.w3.org/2003/01/geo/wgs84_pos#", - lat: "geo:lat", - lng: "geo:long" + geo: 'http://www.w3.org/2003/01/geo/wgs84_pos#', + lat: 'geo:lat', + lng: 'geo:long', }; // FIXME: Fix this tests suite describe('store', { testIsolation: false }, function () { this.beforeAll('visit', () => { - cy.visit('/examples/e2e/store.html') - }) + cy.visit('/examples/e2e/store.html'); + }); it('has prototype', () => { cy.window().then((win: any) => { // properties expect(win.sibStore.cache).to.exist; expect(win.sibStore.subscriptionIndex).to.exist; - expect(win.sibStore.loadingList).to.be.a('Set').and.have.property('size', 0); + expect(win.sibStore.loadingList) + .to.be.a('Set') + .and.have.property('size', 0); expect(win.sibStore.headers).to.exist; // public methods expect(win.sibStore.fetchAuthn).to.be.a('function'); @@ -41,19 +43,19 @@ describe('store', { testIsolation: false }, function () { expect(win.sibStore.selectLanguage).to.be.a('function'); // PubSub expect(win.PubSub).to.exist; - }) + }); }); it('save local data', () => { cy.window().then(async (win: any) => { const store = win.sibStore; - const customID = "myCustomID"; - const url = `store://local.${customID}` + const customID = 'myCustomID'; + const url = `store://local.${customID}`; // Now the context needs to be explicitly defined const dataToSave1 = { foo: 'bar', - "@context": "https://cdn.startinblox.com/owl/context.jsonld" + '@context': 'https://cdn.startinblox.com/owl/context.jsonld', }; await store.setLocalData(dataToSave1, url); let dataRead1 = await store.getData(url); @@ -63,18 +65,21 @@ describe('store', { testIsolation: false }, function () { }); it('replaces local data', () => { - cy.intercept("GET", "*/data/list/users.jsonld").as('users') + cy.intercept('GET', '*/data/list/users.jsonld').as('users'); cy.window().then(async (win: any) => { const store = win.sibStore; await store.getData('/examples/data/list/user-1.jsonld', base_context); const dataToSave1 = { - "@id": "/examples/data/list/user-1.jsonld", - "@type": "foaf:user", - "username": "local user", - "@context": "https://cdn.startinblox.com/owl/context.jsonld" - } - await store.setLocalData(dataToSave1, '/examples/data/list/user-1.jsonld'); + '@id': '/examples/data/list/user-1.jsonld', + '@type': 'foaf:user', + username: 'local user', + '@context': 'https://cdn.startinblox.com/owl/context.jsonld', + }; + await store.setLocalData( + dataToSave1, + '/examples/data/list/user-1.jsonld', + ); const dataRead = store.get('/examples/data/list/user-1.jsonld'); expect(await dataRead['username']).eq('local user'); expect(await dataRead['email']).not.exist; @@ -83,185 +88,160 @@ describe('store', { testIsolation: false }, function () { }); it('fetches data and cache it', () => { - cy.intercept("GET", "/examples/data/list/users.jsonld", { + cy.intercept('GET', '/examples/data/list/users.jsonld', { statusCode: 200, body: { - "@id": "/examples/data/list/users.jsonld", - "@type": "ldp:Container", - "ldp:contains": [ + '@id': '/examples/data/list/users.jsonld', + '@type': 'ldp:Container', + 'ldp:contains': [ { - "@id": "/examples/data/list/user-1.jsonld", - "first_name": "Test", - "last_name": "User", - "name": "Test User", - "username": "admin", - "email": "test-user@example.com", - "available": true, - "years_experience": 3, - "skills": { - "@id": "/examples/data/list/user-1-skills.jsonld", - "@type": "ldp:Container", - "ldp:contains": [ + '@id': '/examples/data/list/user-1.jsonld', + first_name: 'Test', + last_name: 'User', + name: 'Test User', + username: 'admin', + email: 'test-user@example.com', + available: true, + years_experience: 3, + skills: { + '@id': '/examples/data/list/user-1-skills.jsonld', + '@type': 'ldp:Container', + 'ldp:contains': [ { - "@id": "/examples/data/list/skill-2.jsonld" + '@id': '/examples/data/list/skill-2.jsonld', }, { - "@id": "/examples/data/list/skill-3.jsonld" - } + '@id': '/examples/data/list/skill-3.jsonld', + }, ], - "permissions": [ - "view" - ] + permissions: ['view'], }, - "profile": { - "@id": "/examples/data/list/profile-1.jsonld" + profile: { + '@id': '/examples/data/list/profile-1.jsonld', }, - "@type": "foaf:user", - "permissions": [ - "view" - ] + '@type': 'foaf:user', + permissions: ['view'], }, { - "@id": "/examples/data/list/user-2.jsonld", - "first_name": "Paris", - "last_name": "Hilton", - "name": "Paris Hilton", - "username": "paris", - "email": "paris@hilton.hi", - "available": true, - "years_experience": 5, - "skills": { - "@id": "/examples/data/list/user-2-skills.jsonld", - "@type": "ldp:Container", - "ldp:contains": [ + '@id': '/examples/data/list/user-2.jsonld', + first_name: 'Paris', + last_name: 'Hilton', + name: 'Paris Hilton', + username: 'paris', + email: 'paris@hilton.hi', + available: true, + years_experience: 5, + skills: { + '@id': '/examples/data/list/user-2-skills.jsonld', + '@type': 'ldp:Container', + 'ldp:contains': [ { - "@id": "/examples/data/list/skill-1.jsonld" - } + '@id': '/examples/data/list/skill-1.jsonld', + }, ], - "permissions": [ - "view" - ] + permissions: ['view'], }, - "profile": { - "@id": "/examples/data/list/profile-2.jsonld" + profile: { + '@id': '/examples/data/list/profile-2.jsonld', }, - "@type": "foaf:user", - "permissions": [ - "view" - ] + '@type': 'foaf:user', + permissions: ['view'], }, { - "@id": "/examples/data/list/user-4.jsonld", - "first_name": "Pierre", - "last_name": "DLC", - "name": "Pierre DLC", - "username": "pierre", - "email": "pierredelacroix@happy-dev.fr", - "available": false, - "years_experience": 5, - "skills": { - "@id": "/examples/data/list/user-4-skills.jsonld", - "@type": "ldp:Container", - "ldp:contains": [ + '@id': '/examples/data/list/user-4.jsonld', + first_name: 'Pierre', + last_name: 'DLC', + name: 'Pierre DLC', + username: 'pierre', + email: 'pierredelacroix@happy-dev.fr', + available: false, + years_experience: 5, + skills: { + '@id': '/examples/data/list/user-4-skills.jsonld', + '@type': 'ldp:Container', + 'ldp:contains': [ { - "@id": "/examples/data/list/skill-1.jsonld" + '@id': '/examples/data/list/skill-1.jsonld', }, { - "@id": "/examples/data/list/skill-2.jsonld" + '@id': '/examples/data/list/skill-2.jsonld', }, { - "@id": "/examples/data/list/skill-4.jsonld" - } + '@id': '/examples/data/list/skill-4.jsonld', + }, ], - "permissions": [ - "view" - ] + permissions: ['view'], }, - "profile": { - "@id": "/examples/data/list/profile-4.jsonld" + profile: { + '@id': '/examples/data/list/profile-4.jsonld', }, - "@type": "foaf:user", - "permissions": [ - "view" - ] + '@type': 'foaf:user', + permissions: ['view'], }, { - "@id": "/examples/data/list/user-3.jsonld", - "first_name": "Not A", - "last_name": "Paris Member", - "name": "Not A Paris Member", - "username": "not-member-paris", - "email": "not-a@paris.members", - "available": false, - "years_experience": 7, - "skills": { - "@id": "/examples/data/list/user-3-skills.jsonld", - "@type": "ldp:Container", - "ldp:contains": [ - - ], - "permissions": [ - "view" - ] + '@id': '/examples/data/list/user-3.jsonld', + first_name: 'Not A', + last_name: 'Paris Member', + name: 'Not A Paris Member', + username: 'not-member-paris', + email: 'not-a@paris.members', + available: false, + years_experience: 7, + skills: { + '@id': '/examples/data/list/user-3-skills.jsonld', + '@type': 'ldp:Container', + 'ldp:contains': [], + permissions: ['view'], }, - "profile": { - "@id": "/examples/data/list/profile-3.jsonld" + profile: { + '@id': '/examples/data/list/profile-3.jsonld', }, - "@type": "foaf:user", - "permissions": [ - "view" - ] - } - ], - "permissions": [ - "view" + '@type': 'foaf:user', + permissions: ['view'], + }, ], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" + permissions: ['view'], + '@context': 'https://cdn.startinblox.com/owl/context.jsonld', }, headers: { - 'content-type': 'application/ld+json' - } - }).as('users') + 'content-type': 'application/ld+json', + }, + }).as('users'); - cy.intercept("GET", "/examples/data/extra-context/user-6.jsonld", { + cy.intercept('GET', '/examples/data/extra-context/user-6.jsonld', { statusCode: 200, body: { - "@id": "/examples/data/extra-context/user-6.jsonld", - "first_name": "Test", - "last_name": "User", - "username": "admin", - "email": "test-user@example.com", - "name": "Test User", - "profile": { - "@id": "/examples/data/extra-context/profile-6.jsonld", - "@context": { - "picture": "foaf:depiction" + '@id': '/examples/data/extra-context/user-6.jsonld', + first_name: 'Test', + last_name: 'User', + username: 'admin', + email: 'test-user@example.com', + name: 'Test User', + profile: { + '@id': '/examples/data/extra-context/profile-6.jsonld', + '@context': { + picture: 'foaf:depiction', }, - "picture": "my-avatar.png" + picture: 'my-avatar.png', }, - "@type": "foaf:user", - "permissions": [ - "view" - ], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" + '@type': 'foaf:user', + permissions: ['view'], + '@context': 'https://cdn.startinblox.com/owl/context.jsonld', }, headers: { - 'content-type': 'application/ld+json' - } - }).as('user-6') + 'content-type': 'application/ld+json', + }, + }).as('user-6'); cy.window() .its('sibStore') .invoke('getData', '/examples/data/list/users.jsonld', base_context); - cy.get('@users').its("response.statusCode").should('equal', 200); + cy.get('@users').its('response.statusCode').should('equal', 200); - cy.window() - .its('sibStore.cache').should('have.length', 13); // cache - cy.window() - .its('sibStore.loadingList').should('have.property', 'size', 0); // loading list - cy.window() - .its('sibStore.subscriptionIndex').should('have.length', 8); // Subscription index + cy.window().its('sibStore.cache').should('have.length', 13); // cache + cy.window().its('sibStore.loadingList').should('have.property', 'size', 0); // loading list + cy.window().its('sibStore.subscriptionIndex').should('have.length', 8); // Subscription index cy.window() .its('sibStore') @@ -271,57 +251,69 @@ describe('store', { testIsolation: false }, function () { // properties are expanded cy.window() .its('sibStore') - .invoke('getData', '/examples/data/extra-context/user-6.jsonld', base_context); + .invoke( + 'getData', + '/examples/data/extra-context/user-6.jsonld', + base_context, + ); cy.window() .its('sibStore') .invoke('get', '/examples/data/extra-context/user-6.jsonld') .invoke('getResourceData') - .should('have.property', 'https://cdn.startinblox.com/owl#email', "test-user@example.com"); // @vocab + .should( + 'have.property', + 'https://cdn.startinblox.com/owl#email', + 'test-user@example.com', + ); // @vocab cy.window() .its('sibStore') .invoke('get', '/examples/data/extra-context/profile-6.jsonld') .invoke('getResourceData') - .should('have.property', 'http://xmlns.com/foaf/0.1/depiction', "my-avatar.png"); // nested additionnal context + .should( + 'have.property', + 'http://xmlns.com/foaf/0.1/depiction', + 'my-avatar.png', + ); // nested additionnal context }); it('send xhr requests', () => { - cy.intercept("PATCH", "/examples/data/list/user-1.jsonld", { + cy.intercept('PATCH', '/examples/data/list/user-1.jsonld', { headers: { - 'content-type': 'application/ld+json' - } - }).as("patch") - - cy.intercept("PUT", "/examples/data/list/user-1.jsonld", { + 'content-type': 'application/ld+json', + }, + }).as('patch'); + + cy.intercept('PUT', '/examples/data/list/user-1.jsonld', { headers: { - 'content-type': 'application/ld+json' - } - }).as("put") - - cy.intercept("POST", "/examples/data/list/users.jsonld", { + 'content-type': 'application/ld+json', + }, + }).as('put'); + + cy.intercept('POST', '/examples/data/list/users.jsonld', { headers: { - 'content-type': 'application/ld+json' - } - }).as("post") + 'content-type': 'application/ld+json', + }, + }).as('post'); - cy.intercept("DELETE", "/examples/data/list/user-1.jsonld", { + cy.intercept('DELETE', '/examples/data/list/user-1.jsonld', { headers: { - 'content-type': 'application/ld+json' - } - }).as("delete") + 'content-type': 'application/ld+json', + }, + }).as('delete'); - cy.intercept("GET", `${baseUrl}/examples/data/list/user-1.jsonld`, { + cy.intercept('GET', `${baseUrl}/examples/data/list/user-1.jsonld`, { statusCode: 200, body: { - "@id": "/examples/data/list/user-1.jsonld", - "@type": "foaf:user", - "first_name": "Matthieu", - "last_name": "Garcia", - "email": "matthieu@example.com" + '@id': '/examples/data/list/user-1.jsonld', + '@type': 'foaf:user', + first_name: 'Matthieu', + last_name: 'Garcia', + email: 'matthieu@example.com', }, headers: { - 'content-type': 'application/ld+json' - } - }).as("get") + 'content-type': 'application/ld+json', + }, + }).as('get'); cy.window().then((win: any) => { cy.spy(win.sibStore, 'clearCache'); @@ -331,27 +323,49 @@ describe('store', { testIsolation: false }, function () { cy.window() .its('sibStore') .invoke('fetchData', '/examples/data/list/user-1.jsonld'); - cy.get('@get').its("request.url").should('equal', `${baseUrl}/examples/data/list/user-1.jsonld`); - + cy.get('@get') + .its('request.url') + .should('equal', `${baseUrl}/examples/data/list/user-1.jsonld`); + cy.window() .its('sibStore') - .invoke('patch', { first_name: 'Monsieur' }, '/examples/data/list/user-1.jsonld'); - cy.get('@patch').its("request.url").should('equal', `${baseUrl}/examples/data/list/user-1.jsonld`); + .invoke( + 'patch', + { first_name: 'Monsieur' }, + '/examples/data/list/user-1.jsonld', + ); + cy.get('@patch') + .its('request.url') + .should('equal', `${baseUrl}/examples/data/list/user-1.jsonld`); cy.window() .its('sibStore') - .invoke('put', { first_name: 'Monsieur' }, '/examples/data/list/user-1.jsonld'); - cy.get('@put').its("request.url").should('equal', `${baseUrl}/examples/data/list/user-1.jsonld`); + .invoke( + 'put', + { first_name: 'Monsieur' }, + '/examples/data/list/user-1.jsonld', + ); + cy.get('@put') + .its('request.url') + .should('equal', `${baseUrl}/examples/data/list/user-1.jsonld`); cy.window() .its('sibStore') - .invoke('post', { first_name: 'Monsieur' }, '/examples/data/list/users.jsonld'); - cy.get('@post').its("request.url").should('equal', `${baseUrl}/examples/data/list/users.jsonld`); + .invoke( + 'post', + { first_name: 'Monsieur' }, + '/examples/data/list/users.jsonld', + ); + cy.get('@post') + .its('request.url') + .should('equal', `${baseUrl}/examples/data/list/users.jsonld`); cy.window() .its('sibStore') .invoke('delete', '/examples/data/list/user-1.jsonld'); - cy.get('@delete').its("request.url").should('equal', `${baseUrl}/examples/data/list/user-1.jsonld`); + cy.get('@delete') + .its('request.url') + .should('equal', `${baseUrl}/examples/data/list/user-1.jsonld`); cy.window().then((win: any) => { expect(win.sibStore.clearCache).to.be.called; @@ -362,7 +376,9 @@ describe('store', { testIsolation: false }, function () { it('expands id', () => { cy.window() .its('sibStore') - .invoke('_getExpandedId', 'user:1/', { 'user': "https://ldp-server.test/users/" }) + .invoke('_getExpandedId', 'user:1/', { + user: 'https://ldp-server.test/users/', + }) .should('equal', 'https://ldp-server.test/users/1/'); cy.window() @@ -377,8 +393,7 @@ describe('store', { testIsolation: false }, function () { }); it('clears cache', () => { - cy.window() - .its('sibStore.cache').should('have.length', 15); + cy.window().its('sibStore.cache').should('have.length', 15); cy.window() .its('sibStore') @@ -389,26 +404,26 @@ describe('store', { testIsolation: false }, function () { .its('sibStore') .invoke('clearCache', '/examples/data/list/user-1.jsonld'); - cy.window() - .its('sibStore.cache').should('have.length', 14); + cy.window().its('sibStore.cache').should('have.length', 14); cy.window() .its('sibStore') .invoke('get', '/examples/data/list/user-1.jsonld') .should('not.exist'); - cy.window() - .its('sibStore') - .invoke('clearCache', 'wrong-id.jsonld'); + cy.window().its('sibStore').invoke('clearCache', 'wrong-id.jsonld'); - cy.window() - .its('sibStore.cache').should('have.length', 14); + cy.window().its('sibStore.cache').should('have.length', 14); }); it('subscribes resource', () => { cy.window() .its('sibStore') - .invoke('subscribeResourceTo', 'ldp-server.test/circles/', 'ldp-server.test/circles/1/'); + .invoke( + 'subscribeResourceTo', + 'ldp-server.test/circles/', + 'ldp-server.test/circles/1/', + ); cy.window().then((win: any) => { expect(win.sibStore.subscriptionIndex).to.have.length(9); @@ -419,65 +434,117 @@ describe('store', { testIsolation: false }, function () { cy.window() .its('sibStore') - .invoke('subscribeResourceTo', 'ldp-server.test/users/matthieu/', 'ldp-server.test/circles/1/'); + .invoke( + 'subscribeResourceTo', + 'ldp-server.test/users/matthieu/', + 'ldp-server.test/circles/1/', + ); cy.window().then((win: any) => { expect(win.sibStore.subscriptionIndex).to.have.length(9); expect(win.sibStore.subscriptionIndex.get('ldp-server.test/circles/1/')) .to.have.length(2) - .and.to.have.members(['ldp-server.test/circles/', 'ldp-server.test/users/matthieu/']); + .and.to.have.members([ + 'ldp-server.test/circles/', + 'ldp-server.test/users/matthieu/', + ]); }); }); it('subscribes virtual container', () => { cy.window() .its('sibStore') - .invoke('subscribeVirtualContainerTo', 'ldp-server.test/circles/joinable', 'ldp-server.test/circles/1/members'); + .invoke( + 'subscribeVirtualContainerTo', + 'ldp-server.test/circles/joinable', + 'ldp-server.test/circles/1/members', + ); cy.window().then((win: any) => { expect(win.sibStore.subscriptionVirtualContainersIndex).to.have.length(1); - expect(win.sibStore.subscriptionVirtualContainersIndex.get('ldp-server.test/circles/1/members')) + expect( + win.sibStore.subscriptionVirtualContainersIndex.get( + 'ldp-server.test/circles/1/members', + ), + ) .to.have.length(1) .and.to.have.members(['ldp-server.test/circles/joinable']); }); cy.window() .its('sibStore') - .invoke('subscribeVirtualContainerTo', 'ldp-server.test/users/matthieu/circles', 'ldp-server.test/circles/1/members'); + .invoke( + 'subscribeVirtualContainerTo', + 'ldp-server.test/users/matthieu/circles', + 'ldp-server.test/circles/1/members', + ); cy.window().then((win: any) => { expect(win.sibStore.subscriptionVirtualContainersIndex).to.have.length(1); - expect(win.sibStore.subscriptionVirtualContainersIndex.get('ldp-server.test/circles/1/members')) + expect( + win.sibStore.subscriptionVirtualContainersIndex.get( + 'ldp-server.test/circles/1/members', + ), + ) .to.have.length(2) - .and.to.have.members(['ldp-server.test/users/matthieu/circles', 'ldp-server.test/circles/joinable']); + .and.to.have.members([ + 'ldp-server.test/users/matthieu/circles', + 'ldp-server.test/circles/joinable', + ]); }); cy.window() - .its('sibStore') - .invoke('subscribeVirtualContainerTo', 'ldp-server.test/circles/joinable', 'ldp-server.test/circles/1/members'); + .its('sibStore') + .invoke( + 'subscribeVirtualContainerTo', + 'ldp-server.test/circles/joinable', + 'ldp-server.test/circles/1/members', + ); cy.window().then((win: any) => { expect(win.sibStore.subscriptionVirtualContainersIndex).to.have.length(1); - expect(win.sibStore.subscriptionVirtualContainersIndex.get('ldp-server.test/circles/1/members')) + expect( + win.sibStore.subscriptionVirtualContainersIndex.get( + 'ldp-server.test/circles/1/members', + ), + ) .to.have.length(2) - .and.to.have.members(['ldp-server.test/users/matthieu/circles', 'ldp-server.test/circles/joinable']); + .and.to.have.members([ + 'ldp-server.test/users/matthieu/circles', + 'ldp-server.test/circles/joinable', + ]); }); }); it('gets absolute iri', () => { cy.window() .its('sibStore') - .invoke('_getAbsoluteIri', '/examples/data/list/users.jsonld', base_context, '') + .invoke( + '_getAbsoluteIri', + '/examples/data/list/users.jsonld', + base_context, + '', + ) .should('equal', `${baseUrl}/examples/data/list/users.jsonld`); cy.window() .its('sibStore') - .invoke('_getAbsoluteIri', 'user-1.jsonld', base_context, '/examples/data/list/users.jsonld') + .invoke( + '_getAbsoluteIri', + 'user-1.jsonld', + base_context, + '/examples/data/list/users.jsonld', + ) .should('equal', `${baseUrl}/examples/data/list/user-1.jsonld`); cy.window() .its('sibStore') - .invoke('_getAbsoluteIri', 'https://ldp-server.test/circles/', base_context, '') + .invoke( + '_getAbsoluteIri', + 'https://ldp-server.test/circles/', + base_context, + '', + ) .should('equal', 'https://ldp-server.test/circles/'); }); @@ -488,28 +555,34 @@ describe('store', { testIsolation: false }, function () { await store.getData('/examples/data/list/user-1.jsonld', base_context); const resource = { - "@id": "/examples/data/list/user-1.jsonld", - name: "Test User", + '@id': '/examples/data/list/user-1.jsonld', + name: 'Test User', available: true, skills: { - "@id": "/examples/data/list/user-1-skills.jsonld", - "@type": "ldp:Container", - "ldp:contains": [ + '@id': '/examples/data/list/user-1-skills.jsonld', + '@type': 'ldp:Container', + 'ldp:contains': [ { - "@id": "/examples/data/list/skill-2.jsonld" + '@id': '/examples/data/list/skill-2.jsonld', }, { - "@id": "/examples/data/list/skill-3.jsonld" - } + '@id': '/examples/data/list/skill-3.jsonld', + }, ], }, profile: { - "@id": "/examples/data/list/profile-1.jsonld" + '@id': '/examples/data/list/profile-1.jsonld', }, - "@type": "foaf:user" + '@type': 'foaf:user', }; - const nestedResources = await store.getNestedResources(resource, '/examples/data/list/user-1.jsonld'); - expect(nestedResources).to.deep.equal(["/examples/data/list/user-1-skills.jsonld", "/examples/data/list/profile-1.jsonld"]); + const nestedResources = await store.getNestedResources( + resource, + '/examples/data/list/user-1.jsonld', + ); + expect(nestedResources).to.deep.equal([ + '/examples/data/list/user-1-skills.jsonld', + '/examples/data/list/profile-1.jsonld', + ]); expect(store.fetchData).to.be.calledOnce; }); }); @@ -522,7 +595,10 @@ describe('store', { testIsolation: false }, function () { cy.spy(store, 'fetchData'); expect(store.cache).to.have.length(15); - await store.refreshResources(['/examples/data/list/user-1.jsonld', '/examples/data/list/users.jsonld']); + await store.refreshResources([ + '/examples/data/list/user-1.jsonld', + '/examples/data/list/users.jsonld', + ]); expect(store.clearCache).to.be.calledTwice; expect(store.getData).to.be.calledTwice; @@ -536,7 +612,10 @@ describe('store', { testIsolation: false }, function () { cy.window().then(async (win: any) => { const store = win.sibStore; cy.spy(win.PubSub, 'publish'); - await store.notifyResources(['/examples/data/list/user-1.jsonld', '/examples/data/list/users.jsonld']); + await store.notifyResources([ + '/examples/data/list/user-1.jsonld', + '/examples/data/list/users.jsonld', + ]); expect(win.PubSub.publish).to.be.calledTwice; }); }); @@ -544,24 +623,30 @@ describe('store', { testIsolation: false }, function () { it('refreshResource and localData', () => { cy.window().then(async (win: any) => { const store = win.sibStore; - await store.setLocalData({ - "@context": "https://cdn.startinblox.com/owl/context.jsonld", - "@id": "store://local.2", - "name": "ok", - }, "store://local.2"); - - await store.setLocalData({ - "@context": "https://cdn.startinblox.com/owl/context.jsonld", - "@id": "store://local.1", - "ref": { "@id": "store://local.2" }, - }, "store://local.1"); + await store.setLocalData( + { + '@context': 'https://cdn.startinblox.com/owl/context.jsonld', + '@id': 'store://local.2', + name: 'ok', + }, + 'store://local.2', + ); + + await store.setLocalData( + { + '@context': 'https://cdn.startinblox.com/owl/context.jsonld', + '@id': 'store://local.1', + ref: { '@id': 'store://local.2' }, + }, + 'store://local.1', + ); cy.wait(100).then(async () => { - const resource = store.get('store://local.2') + const resource = store.get('store://local.2'); expect(resource).to.exist; - const name = await resource['name'] + const name = await resource['name']; expect(name).to.equal('ok'); - } ); + }); }); }); -}); \ No newline at end of file +}); diff --git a/cypress/fixtures/circles-16.jsonld b/cypress/fixtures/circles-16.jsonld index 2153cd98..8def997c 100644 --- a/cypress/fixtures/circles-16.jsonld +++ b/cypress/fixtures/circles-16.jsonld @@ -10,10 +10,6 @@ "@id": "https://ldp-server.test/users/matthieu/" }, "@type": "hd:circle", - "permissions": [ - "view", - "change", - "delete" - ], + "permissions": ["view", "change", "delete"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/cypress/fixtures/circles-17-members.jsonld b/cypress/fixtures/circles-17-members.jsonld index 22c625e2..7a26fc37 100644 --- a/cypress/fixtures/circles-17-members.jsonld +++ b/cypress/fixtures/circles-17-members.jsonld @@ -1,11 +1,7 @@ { "@id": "https://ldp-server.test/circles/17/members/", "@type": "ldp:Container", - "ldp:contains": [ - ], - "permissions": [ - "add", - "view" - ], + "ldp:contains": [], + "permissions": ["add", "view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/cypress/fixtures/oembed.jsonld b/cypress/fixtures/oembed.jsonld index 95a03703..2abbe728 100644 --- a/cypress/fixtures/oembed.jsonld +++ b/cypress/fixtures/oembed.jsonld @@ -13,4 +13,3 @@ "thumbnail_url": "https://i.ytimg.com/vi/M3r2XDceM6A/hqdefault.jpg", "html": "<iframe width=\"200\" height=\"113\" src=\"https://www.youtube.com/embed/M3r2XDceM6A?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>" } - \ No newline at end of file diff --git a/cypress/fixtures/profiles-alex.jsonld b/cypress/fixtures/profiles-alex.jsonld index 927901f9..0f8a2ca7 100644 --- a/cypress/fixtures/profiles-alex.jsonld +++ b/cypress/fixtures/profiles-alex.jsonld @@ -9,8 +9,6 @@ "user": { "@id": "https://ldp-server.test/users/alex/" }, - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/cypress/fixtures/profiles-jbpasquier.jsonld b/cypress/fixtures/profiles-jbpasquier.jsonld index 943f90f4..c5c49ddc 100644 --- a/cypress/fixtures/profiles-jbpasquier.jsonld +++ b/cypress/fixtures/profiles-jbpasquier.jsonld @@ -9,8 +9,6 @@ "user": { "@id": "https://ldp-server.test/users/jbpasquier/" }, - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/cypress/fixtures/profiles-matthieu-edited-2.jsonld b/cypress/fixtures/profiles-matthieu-edited-2.jsonld index 2cf1a1eb..7fed20f5 100644 --- a/cypress/fixtures/profiles-matthieu-edited-2.jsonld +++ b/cypress/fixtures/profiles-matthieu-edited-2.jsonld @@ -9,8 +9,6 @@ "user": { "@id": "https://ldp-server.test/users/matthieu/" }, - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/cypress/fixtures/profiles-matthieu-edited.jsonld b/cypress/fixtures/profiles-matthieu-edited.jsonld index 1d3e0d34..e5150930 100644 --- a/cypress/fixtures/profiles-matthieu-edited.jsonld +++ b/cypress/fixtures/profiles-matthieu-edited.jsonld @@ -9,8 +9,6 @@ "user": { "@id": "https://ldp-server.test/users/matthieu/" }, - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/cypress/fixtures/profiles-matthieu.jsonld b/cypress/fixtures/profiles-matthieu.jsonld index 5a1b6638..5c47e163 100644 --- a/cypress/fixtures/profiles-matthieu.jsonld +++ b/cypress/fixtures/profiles-matthieu.jsonld @@ -9,8 +9,6 @@ "user": { "@id": "https://ldp-server.test/users/matthieu/" }, - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/cypress/fixtures/users-alex.jsonld b/cypress/fixtures/users-alex.jsonld index f9e6284e..64506e77 100644 --- a/cypress/fixtures/users-alex.jsonld +++ b/cypress/fixtures/users-alex.jsonld @@ -15,8 +15,5 @@ "get_full_name": "rdfs:label" } ], - "permissions": [ - "view", - "change" - ] + "permissions": ["view", "change"] } diff --git a/cypress/fixtures/users-edited.jsonld b/cypress/fixtures/users-edited.jsonld index 5f518d91..8a204e56 100644 --- a/cypress/fixtures/users-edited.jsonld +++ b/cypress/fixtures/users-edited.jsonld @@ -16,10 +16,7 @@ "@context": { "get_full_name": "rdfs:label" }, - "permissions": [ - "view", - "change" - ] + "permissions": ["view", "change"] }, { "@id": "https://ldp-server.test/users/jbpasquier/", @@ -35,9 +32,7 @@ "@context": { "get_full_name": "rdfs:label" }, - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "https://ldp-server.test/users/alex/", @@ -53,14 +48,9 @@ "@context": { "get_full_name": "rdfs:label" }, - "permissions": [ - "view" - ] + "permissions": ["view"] } ], - "permissions": [ - "add", - "view" - ], + "permissions": ["add", "view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/cypress/fixtures/users-jbpasquier.jsonld b/cypress/fixtures/users-jbpasquier.jsonld index bc5472ae..392e5a7d 100644 --- a/cypress/fixtures/users-jbpasquier.jsonld +++ b/cypress/fixtures/users-jbpasquier.jsonld @@ -15,8 +15,5 @@ "get_full_name": "rdfs:label" } ], - "permissions": [ - "view", - "change" - ] + "permissions": ["view", "change"] } diff --git a/cypress/fixtures/users-matthieu-circles-edited.jsonld b/cypress/fixtures/users-matthieu-circles-edited.jsonld index 0defa5d0..8dfa8711 100644 --- a/cypress/fixtures/users-matthieu-circles-edited.jsonld +++ b/cypress/fixtures/users-matthieu-circles-edited.jsonld @@ -12,10 +12,7 @@ "name": "circle one" }, "@type": "hd:circlemember", - "permissions": [ - "view", - "delete" - ] + "permissions": ["view", "delete"] }, { "@id": "https://ldp-server.test/circle-members/127/", @@ -27,15 +24,9 @@ "name": "circle two" }, "@type": "hd:circlemember", - "permissions": [ - "view", - "delete" - ] + "permissions": ["view", "delete"] } ], - "permissions": [ - "add", - "view" - ], + "permissions": ["add", "view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/cypress/fixtures/users-matthieu-circles.jsonld b/cypress/fixtures/users-matthieu-circles.jsonld index 9a59dfb8..21fe2692 100644 --- a/cypress/fixtures/users-matthieu-circles.jsonld +++ b/cypress/fixtures/users-matthieu-circles.jsonld @@ -12,15 +12,9 @@ "name": "circle one" }, "@type": "hd:circlemember", - "permissions": [ - "view", - "delete" - ] + "permissions": ["view", "delete"] } ], - "permissions": [ - "add", - "view" - ], + "permissions": ["add", "view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/cypress/fixtures/users-matthieu-edited.jsonld b/cypress/fixtures/users-matthieu-edited.jsonld index 1b9e7ceb..5d8134e6 100644 --- a/cypress/fixtures/users-matthieu-edited.jsonld +++ b/cypress/fixtures/users-matthieu-edited.jsonld @@ -15,8 +15,5 @@ "get_full_name": "rdfs:label" } ], - "permissions": [ - "view", - "change" - ] + "permissions": ["view", "change"] } diff --git a/cypress/fixtures/users-matthieu.jsonld b/cypress/fixtures/users-matthieu.jsonld index 5154239a..ecc6e12b 100644 --- a/cypress/fixtures/users-matthieu.jsonld +++ b/cypress/fixtures/users-matthieu.jsonld @@ -15,8 +15,5 @@ "get_full_name": "rdfs:label" } ], - "permissions": [ - "view", - "change" - ] + "permissions": ["view", "change"] } diff --git a/cypress/fixtures/users-nantes.jsonld b/cypress/fixtures/users-nantes.jsonld index 4380d829..7a6d3a3a 100644 --- a/cypress/fixtures/users-nantes.jsonld +++ b/cypress/fixtures/users-nantes.jsonld @@ -16,14 +16,9 @@ "@context": { "get_full_name": "rdfs:label" }, - "permissions": [ - "view" - ] + "permissions": ["view"] } ], - "permissions": [ - "add", - "view" - ], + "permissions": ["add", "view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/cypress/fixtures/users-paris.jsonld b/cypress/fixtures/users-paris.jsonld index e7be80ce..7647ca2c 100644 --- a/cypress/fixtures/users-paris.jsonld +++ b/cypress/fixtures/users-paris.jsonld @@ -16,10 +16,7 @@ "@context": { "get_full_name": "rdfs:label" }, - "permissions": [ - "view", - "change" - ] + "permissions": ["view", "change"] }, { "@id": "https://ldp-server.test/users/jbpasquier/", @@ -35,14 +32,9 @@ "@context": { "get_full_name": "rdfs:label" }, - "permissions": [ - "view" - ] + "permissions": ["view"] } ], - "permissions": [ - "add", - "view" - ], + "permissions": ["add", "view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/cypress/fixtures/users-source.jsonld b/cypress/fixtures/users-source.jsonld index 9058bca6..459ef51e 100644 --- a/cypress/fixtures/users-source.jsonld +++ b/cypress/fixtures/users-source.jsonld @@ -6,21 +6,15 @@ "federation": "users", "@id": "https://ldp-server.test/users/", "@type": "sib:federatedContainer", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "federation": "users", "@id": "https://ldp-server2.test/users/", "@type": "sib:federatedContainer", - "permissions": [ - "view" - ] + "permissions": ["view"] } ], - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/cypress/index.d.ts b/cypress/index.d.ts index 6f0b0745..b7592dd7 100644 --- a/cypress/index.d.ts +++ b/cypress/index.d.ts @@ -1,14 +1,13 @@ - declare namespace Cypress { interface Chainable { /** * Load file in <input type="file"> * @example cy.get('input[type=file]').uploadFile('./img/image.jpg') - */ - uploadFile(fileName: string): Chainable<Element> + */ + uploadFile(fileName: string): Chainable<Element>; } } interface Window { - sibStore: any -} \ No newline at end of file + sibStore: any; +} diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 11869a8c..ab88c966 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -24,16 +24,20 @@ // -- This will overwrite an existing command -- // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) -Cypress.Commands.add('uploadFile', { prevSubject: true }, (subject, fileName) => { - cy.fixture(fileName).then((content) => { - const el = subject[0] - const testFile = new File([content], fileName) - const dataTransfer = new DataTransfer() - dataTransfer.items.add(testFile) - el.files = dataTransfer.files - cy.wrap(subject).trigger('change', { force: true }) - }) -}); +Cypress.Commands.add( + 'uploadFile', + { prevSubject: true }, + (subject, fileName) => { + cy.fixture(fileName).then(content => { + const el = subject[0]; + const testFile = new File([content], fileName); + const dataTransfer = new DataTransfer(); + dataTransfer.items.add(testFile); + el.files = dataTransfer.files; + cy.wrap(subject).trigger('change', { force: true }); + }); + }, +); Cypress.Commands.add('iframe', { prevSubject: 'element' }, $iframe => { return new Cypress.Promise(resolve => { @@ -41,4 +45,4 @@ Cypress.Commands.add('iframe', { prevSubject: 'element' }, $iframe => { resolve($iframe.contents().find('body')); }); }); -}); \ No newline at end of file +}); diff --git a/cypress/support/e2e.js b/cypress/support/e2e.js index 537ef46f..3cb1fbe5 100644 --- a/cypress/support/e2e.js +++ b/cypress/support/e2e.js @@ -14,7 +14,7 @@ // *********************************************************** // Import commands.js using ES2015 syntax: -import './commands' +import './commands'; // Alternatively you can use CommonJS syntax: // require('./commands') @@ -25,5 +25,5 @@ import '@rckeller/cypress-unfetch'; import 'cypress-plugin-tab'; Cypress.on('uncaught:exception', () => { - return false -}) + return false; +}); diff --git a/examples/data/calendar/event-1.jsonld b/examples/data/calendar/event-1.jsonld index d7d6820f..237a3912 100644 --- a/examples/data/calendar/event-1.jsonld +++ b/examples/data/calendar/event-1.jsonld @@ -1,7 +1,7 @@ { - "@id": "/examples/data/calendar/event-1.jsonld", - "name": "Test", - "deadline": "2019-09-09T19:55:44Z", - "permissions": [], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" + "@id": "/examples/data/calendar/event-1.jsonld", + "name": "Test", + "deadline": "2019-09-09T19:55:44Z", + "permissions": [], + "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/calendar/event-2.jsonld b/examples/data/calendar/event-2.jsonld index e27b3498..cc4a3931 100644 --- a/examples/data/calendar/event-2.jsonld +++ b/examples/data/calendar/event-2.jsonld @@ -1,7 +1,7 @@ { - "@id": "/examples/data/calendar/event-2.jsonld", - "name": "Test demain", - "deadline": "2019-09-10T19:55:56Z", - "permissions": [], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" + "@id": "/examples/data/calendar/event-2.jsonld", + "name": "Test demain", + "deadline": "2019-09-10T19:55:56Z", + "permissions": [], + "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/calendar/events.jsonld b/examples/data/calendar/events.jsonld index d539f88e..d04aef77 100644 --- a/examples/data/calendar/events.jsonld +++ b/examples/data/calendar/events.jsonld @@ -1,16 +1,19 @@ { - "@type": "ldp:Container", - "ldp:contains": [{ - "@id": "/examples/data/calendar/event-1.jsonld", - "name": "Test", - "deadline": "2019-09-09T19:55:44Z", - "permissions": [] - }, { - "@id": "/examples/data/calendar/event-2.jsonld", - "name": "Test demain", - "deadline": "2019-09-10T19:55:56Z", - "permissions": [] - }], - "@id": "/examples/data/calendar/events.jsonld", - "@context": "https://cdn.startinblox.com/owl/context.jsonld" + "@type": "ldp:Container", + "ldp:contains": [ + { + "@id": "/examples/data/calendar/event-1.jsonld", + "name": "Test", + "deadline": "2019-09-09T19:55:44Z", + "permissions": [] + }, + { + "@id": "/examples/data/calendar/event-2.jsonld", + "name": "Test demain", + "deadline": "2019-09-10T19:55:56Z", + "permissions": [] + } + ], + "@id": "/examples/data/calendar/events.jsonld", + "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/carrot.jsonld b/examples/data/carrot.jsonld index 86eb0aad..9fd84be6 100644 --- a/examples/data/carrot.jsonld +++ b/examples/data/carrot.jsonld @@ -11,11 +11,5 @@ "dfc-b:hasType": { "@id": "dfc-pt:carrot" }, - "permissions": [ - "view", - "control", - "add", - "delete", - "change" - ] -} \ No newline at end of file + "permissions": ["view", "control", "add", "delete", "change"] +} diff --git a/examples/data/dfc-enterprise.jsonld b/examples/data/dfc-enterprise.jsonld index 59c979fa..76b20af8 100644 --- a/examples/data/dfc-enterprise.jsonld +++ b/examples/data/dfc-enterprise.jsonld @@ -52,11 +52,5 @@ "dfc-b:offeredThrough": "http://test.host/api/dfc/enterprises/10000/offers/10001" } ], - "permissions": [ - "view", - "control", - "add", - "delete", - "change" - ] -} \ No newline at end of file + "permissions": ["view", "control", "add", "delete", "change"] +} diff --git a/examples/data/empty-container.jsonld b/examples/data/empty-container.jsonld index 5251752e..c3f49e87 100644 --- a/examples/data/empty-container.jsonld +++ b/examples/data/empty-container.jsonld @@ -2,12 +2,6 @@ "@id": "/examples/data/empty-container.jsonld", "@type": "ldp:Container", "ldp:contains": [], - "permissions": [ - "view", - "control", - "add", - "delete", - "change" - ], + "permissions": ["view", "control", "add", "delete", "change"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/extra-context/user-1.jsonld b/examples/data/extra-context/user-1.jsonld index 1eb8d30d..f3626b93 100644 --- a/examples/data/extra-context/user-1.jsonld +++ b/examples/data/extra-context/user-1.jsonld @@ -6,8 +6,6 @@ "email": "test-user@example.com", "name": "Test User", "@type": "foaf:user", - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/extra-context/user-2.jsonld b/examples/data/extra-context/user-2.jsonld index b71760ab..c6cbf400 100644 --- a/examples/data/extra-context/user-2.jsonld +++ b/examples/data/extra-context/user-2.jsonld @@ -6,8 +6,6 @@ "email": "paris@hilton.hi", "name": "Paris Hilton", "@type": "foaf:user", - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/extra-context/user-6.jsonld b/examples/data/extra-context/user-6.jsonld index e94bd05e..d5c36131 100644 --- a/examples/data/extra-context/user-6.jsonld +++ b/examples/data/extra-context/user-6.jsonld @@ -13,8 +13,6 @@ "picture": "my-avatar.png" }, "@type": "foaf:user", - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/extra-context/users.jsonld b/examples/data/extra-context/users.jsonld index e8e0d5da..0085b852 100644 --- a/examples/data/extra-context/users.jsonld +++ b/examples/data/extra-context/users.jsonld @@ -10,9 +10,7 @@ "email": "test-user@example.com", "name": "Test User", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "http://localhost:3000/examples/data/extra-context/user-2.jsonld", @@ -22,13 +20,9 @@ "email": "paris@hilton.hi", "name": "Paris Hilton", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] } ], - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/federation/circles-server1.jsonld b/examples/data/federation/circles-server1.jsonld index cdc45002..ced7e406 100644 --- a/examples/data/federation/circles-server1.jsonld +++ b/examples/data/federation/circles-server1.jsonld @@ -13,9 +13,7 @@ "jabberID": "3oa55lvwyzs6@conference.test1.startinblox.com", "jabberRoom": true, "@type": "hd:circle", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/federation/circles-2.jsonld", @@ -28,14 +26,9 @@ "jabberID": "3oa55lvwyqq6@conference.test1.startinblox.com", "jabberRoom": true, "@type": "hd:circle", - "permissions": [ - "view" - ] + "permissions": ["view"] } ], - "permissions": [ - "add", - "view" - ], + "permissions": ["add", "view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/federation/circles-server2.jsonld b/examples/data/federation/circles-server2.jsonld index 064c55d3..63de5a56 100644 --- a/examples/data/federation/circles-server2.jsonld +++ b/examples/data/federation/circles-server2.jsonld @@ -13,9 +13,7 @@ "jabberID": "3oa5aaaazee6@conference.test1.startinblox.com", "jabberRoom": true, "@type": "hd:circle", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/federation/circles-4.jsonld", @@ -28,14 +26,9 @@ "jabberID": "3oa55lvwyqq6@conference.test1.startinblox.com", "jabberRoom": true, "@type": "hd:circle", - "permissions": [ - "view" - ] + "permissions": ["view"] } ], - "permissions": [ - "add", - "view" - ], + "permissions": ["add", "view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/federation/circles-server3.jsonld b/examples/data/federation/circles-server3.jsonld index 106257fc..8dfc96e2 100644 --- a/examples/data/federation/circles-server3.jsonld +++ b/examples/data/federation/circles-server3.jsonld @@ -13,9 +13,7 @@ "jabberID": "3oa5aaaazee6@conference.test1.startinblox.com", "jabberRoom": true, "@type": "hd:circle", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/federation/circles-1.jsonld", @@ -28,14 +26,9 @@ "jabberID": "3oa55lvwyzs6@conference.test1.startinblox.com", "jabberRoom": true, "@type": "hd:circle", - "permissions": [ - "view" - ] + "permissions": ["view"] } ], - "permissions": [ - "add", - "view" - ], + "permissions": ["add", "view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/federation/circles-server4.jsonld b/examples/data/federation/circles-server4.jsonld index 2567bcfd..9b86be16 100644 --- a/examples/data/federation/circles-server4.jsonld +++ b/examples/data/federation/circles-server4.jsonld @@ -13,14 +13,9 @@ "jabberID": "3oa5aaaazee6@conference.test1.startinblox.com", "jabberRoom": true, "@type": "hd:circle", - "permissions": [ - "view" - ] + "permissions": ["view"] } ], - "permissions": [ - "add", - "view" - ], + "permissions": ["add", "view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/federation/nested-source.jsonld b/examples/data/federation/nested-source.jsonld index dbc759f9..12f8db3c 100644 --- a/examples/data/federation/nested-source.jsonld +++ b/examples/data/federation/nested-source.jsonld @@ -6,9 +6,7 @@ "federation": "circles", "@id": "/examples/data/federation/circles-server1.jsonld", "@type": "sib:federatedContainer", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/federation/circles-server2.jsonld", @@ -23,8 +21,6 @@ "@type": "sib:federatedContainer" } ], - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/federation/source1.jsonld b/examples/data/federation/source1.jsonld index 12e8c65c..35746465 100644 --- a/examples/data/federation/source1.jsonld +++ b/examples/data/federation/source1.jsonld @@ -6,17 +6,13 @@ "federation": "circles", "@id": "/examples/data/federation/circles-server1.jsonld", "@type": "sib:federatedContainer", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/federation/circles-server2.jsonld", "@type": "sib:federatedContainer" } ], - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/federation/source2.jsonld b/examples/data/federation/source2.jsonld index 91a2a8e9..5d2b0818 100644 --- a/examples/data/federation/source2.jsonld +++ b/examples/data/federation/source2.jsonld @@ -6,17 +6,13 @@ "federation": "circles", "@id": "/examples/data/federation/circles-server3.jsonld", "@type": "sib:federatedContainer", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/federation/circles-server4.jsonld", "@type": "sib:federatedContainer" } ], - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/galaxy.jsonld b/examples/data/galaxy.jsonld index 72e86a46..19603f08 100644 --- a/examples/data/galaxy.jsonld +++ b/examples/data/galaxy.jsonld @@ -179,11 +179,5 @@ } } ], - "permissions": [ - "view", - "control", - "add", - "delete", - "change" - ] -} \ No newline at end of file + "permissions": ["view", "control", "add", "delete", "change"] +} diff --git a/examples/data/groups/group1.jsonld b/examples/data/groups/group1.jsonld index 7537d634..658ee380 100644 --- a/examples/data/groups/group1.jsonld +++ b/examples/data/groups/group1.jsonld @@ -8,8 +8,6 @@ "@id": "/examples/data/list/--user-2.jsonld" } ], - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/image.jsonld b/examples/data/image.jsonld index 532b474c..e9625b97 100644 --- a/examples/data/image.jsonld +++ b/examples/data/image.jsonld @@ -4,11 +4,5 @@ "description": "basket containing apples, oranges, kiwis, bananas, pineapples\u2026", "picture": "../../upload/fruits.jpg", "@context": "https://cdn.startinblox.com/owl/context.jsonld", - "permissions": [ - "view", - "control", - "add", - "delete", - "change" - ] -} \ No newline at end of file + "permissions": ["view", "control", "add", "delete", "change"] +} diff --git a/examples/data/list/chewbacca.jsonld b/examples/data/list/chewbacca.jsonld index 2a94287b..ffeec6d6 100644 --- a/examples/data/list/chewbacca.jsonld +++ b/examples/data/list/chewbacca.jsonld @@ -1,5 +1,5 @@ { - "@id": "/examples/data/list/examples/data/list/chewbacca.jsonld", - "name": "Chewbacca", - "@context": "https://cdn.startinblox.com/owl/context.jsonld" + "@id": "/examples/data/list/examples/data/list/chewbacca.jsonld", + "name": "Chewbacca", + "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/list/colibris.jsonld b/examples/data/list/colibris.jsonld index f47c67f8..4204ed56 100644 --- a/examples/data/list/colibris.jsonld +++ b/examples/data/list/colibris.jsonld @@ -5,139 +5,71 @@ "ldp:contains": [ { "@id": "/examples/data/list/universite.jsonld", - "@type": [ - "ldp:Container", - "ldp:BasicContainer", - "ldp:Resource" - ] + "@type": ["ldp:Container", "ldp:BasicContainer", "ldp:Resource"] }, { "@id": "/examples/data/list/bots.jsonld", - "@type": [ - "ldp:Container", - "ldp:BasicContainer", - "ldp:Resource" - ] + "@type": ["ldp:Container", "ldp:BasicContainer", "ldp:Resource"] }, { "@id": "/examples/data/list/miniparcours", - "@type": [ - "ldp:Container", - "ldp:BasicContainer", - "ldp:Resource" - ] + "@type": ["ldp:Container", "ldp:BasicContainer", "ldp:Resource"] }, { "@id": "/examples/data/list/users", - "@type": [ - "ldp:BasicContainer", - "ldp:Container", - "ldp:Resource" - ] + "@type": ["ldp:BasicContainer", "ldp:Container", "ldp:Resource"] }, { "@id": "/examples/data/list/lafabrique", - "@type": [ - "ldp:Container", - "ldp:BasicContainer", - "ldp:Resource" - ] + "@type": ["ldp:Container", "ldp:BasicContainer", "ldp:Resource"] }, { "@id": "/examples/data/list/laboutique", - "@type": [ - "ldp:Container", - "ldp:BasicContainer", - "ldp:Resource" - ] + "@type": ["ldp:Container", "ldp:BasicContainer", "ldp:Resource"] }, { "@id": "/examples/data/list/lemouvement", - "@type": [ - "ldp:Container", - "ldp:BasicContainer", - "ldp:Resource" - ] + "@type": ["ldp:Container", "ldp:BasicContainer", "ldp:Resource"] }, { "@id": "/examples/data/list/groupeslocaux", - "@type": [ - "ldp:Container", - "ldp:BasicContainer", - "ldp:Resource" - ] + "@type": ["ldp:Container", "ldp:BasicContainer", "ldp:Resource"] }, { "@id": "/examples/data/list/activities", - "@type": [ - "ldp:BasicContainer", - "ldp:Container", - "ldp:Resource" - ] + "@type": ["ldp:BasicContainer", "ldp:Container", "ldp:Resource"] }, { "@id": "/examples/data/list/lemag", - "@type": [ - "ldp:Container", - "ldp:BasicContainer", - "ldp:Resource" - ] + "@type": ["ldp:Container", "ldp:BasicContainer", "ldp:Resource"] }, { "@id": "/examples/data/list/status", - "@type": [ - "ldp:Container", - "ldp:BasicContainer", - "ldp:Resource" - ] + "@type": ["ldp:Container", "ldp:BasicContainer", "ldp:Resource"] }, { "@id": "/examples/data/list/themes", - "@type": [ - "ldp:Container", - "ldp:BasicContainer", - "ldp:Resource" - ] + "@type": ["ldp:Container", "ldp:BasicContainer", "ldp:Resource"] }, { "@id": "/examples/data/list/files", - "@type": [ - "ldp:BasicContainer", - "ldp:Container", - "ldp:Resource" - ] + "@type": ["ldp:BasicContainer", "ldp:Container", "ldp:Resource"] }, { "@id": "/examples/data/list/@types", - "@type": [ - "ldp:Container", - "ldp:BasicContainer", - "ldp:Resource" - ] + "@type": ["ldp:Container", "ldp:BasicContainer", "ldp:Resource"] }, { "@id": "/examples/data/list/services", - "@type": [ - "ldp:Container", - "ldp:BasicContainer", - "ldp:Resource" - ] + "@type": ["ldp:Container", "ldp:BasicContainer", "ldp:Resource"] }, { "@id": "/examples/data/list/skills", - "@type": [ - "ldp:Container", - "ldp:BasicContainer", - "ldp:Resource" - ] + "@type": ["ldp:Container", "ldp:BasicContainer", "ldp:Resource"] }, { "@id": "/examples/data/list/presdecheznous", - "@type": [ - "ldp:Container", - "ldp:BasicContainer", - "ldp:Resource" - ] + "@type": ["ldp:Container", "ldp:BasicContainer", "ldp:Resource"] } ] } diff --git a/examples/data/list/community-group.jsonld b/examples/data/list/community-group.jsonld index eafa7d00..300f75a1 100644 --- a/examples/data/list/community-group.jsonld +++ b/examples/data/list/community-group.jsonld @@ -33,7 +33,5 @@ "user_set": "foaf:member" } ], - "permissions": [ - "view" - ] + "permissions": ["view"] } diff --git a/examples/data/list/darth-vader.json b/examples/data/list/darth-vader.json index b6b8d6d3..912d99ac 100644 --- a/examples/data/list/darth-vader.json +++ b/examples/data/list/darth-vader.json @@ -1,5 +1,5 @@ { - "@id": "/examples/data/list/examples/data/list/darth-vader.json", - "name": "Darth Vader", - "@context": "https://cdn.startinblox.com/owl/context.jsonld" + "@id": "/examples/data/list/examples/data/list/darth-vader.json", + "name": "Darth Vader", + "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/list/event-1.jsonld b/examples/data/list/event-1.jsonld index be932c4d..2695942f 100644 --- a/examples/data/list/event-1.jsonld +++ b/examples/data/list/event-1.jsonld @@ -1,12 +1,12 @@ { - "@id": "/examples/data/list/event-1.jsonld", - "name": "Coliving", - "date": "2020-07-09", - "seats": 12, - "description": "some description", - "contact": { - "@id": "/examples/data/list/user-1.jsonld" - }, - "permissions": [], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" + "@id": "/examples/data/list/event-1.jsonld", + "name": "Coliving", + "date": "2020-07-09", + "seats": 12, + "description": "some description", + "contact": { + "@id": "/examples/data/list/user-1.jsonld" + }, + "permissions": [], + "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/list/event-2.jsonld b/examples/data/list/event-2.jsonld index 63a03877..5ead3824 100644 --- a/examples/data/list/event-2.jsonld +++ b/examples/data/list/event-2.jsonld @@ -1,11 +1,11 @@ { - "@id": "/examples/data/list/event-2.jsonld", - "name": "Workshop", - "date": "2020-05-10", - "seats": 2, - "contact": { - "@id": "/examples/data/list/user-2.jsonld" - }, - "permissions": [], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" + "@id": "/examples/data/list/event-2.jsonld", + "name": "Workshop", + "date": "2020-05-10", + "seats": 2, + "contact": { + "@id": "/examples/data/list/user-2.jsonld" + }, + "permissions": [], + "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/list/event-3.jsonld b/examples/data/list/event-3.jsonld index 7b60d507..f147886c 100644 --- a/examples/data/list/event-3.jsonld +++ b/examples/data/list/event-3.jsonld @@ -1,11 +1,11 @@ { - "@id": "/examples/data/list/event-3.jsonld", - "name": "Réunion d'information", - "date": "2020-07-10", - "seats": 230, - "contact": { - "@id": "/examples/data/list/user-3.jsonld" - }, - "permissions": [], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" + "@id": "/examples/data/list/event-3.jsonld", + "name": "Réunion d'information", + "date": "2020-07-10", + "seats": 230, + "contact": { + "@id": "/examples/data/list/user-3.jsonld" + }, + "permissions": [], + "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/list/event-4.jsonld b/examples/data/list/event-4.jsonld index f93aa927..0bb93598 100644 --- a/examples/data/list/event-4.jsonld +++ b/examples/data/list/event-4.jsonld @@ -1,11 +1,11 @@ { - "@id": "/examples/data/list/event-4.jsonld", - "name": "Assemblée générale", - "date": "2020-05-10", - "seats": 55, - "contact": { - "@id": "/examples/data/list/user-4.jsonld" - }, - "permissions": [], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" + "@id": "/examples/data/list/event-4.jsonld", + "name": "Assemblée générale", + "date": "2020-05-10", + "seats": 55, + "contact": { + "@id": "/examples/data/list/user-4.jsonld" + }, + "permissions": [], + "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/list/event-5.jsonld b/examples/data/list/event-5.jsonld index e81d0a81..4e9540f5 100644 --- a/examples/data/list/event-5.jsonld +++ b/examples/data/list/event-5.jsonld @@ -1,67 +1,67 @@ { - "@type": "ldp:Container", - "ldp:contains": [ - { - "@id": "/examples/data/list/event-1.jsonld", - "name": "Coliving", - "date": "2020-07-09", - "year": 2020, - "seats": 12, - "place":"", - "city":"", - "permissions": [] - }, - { - "@id": "/examples/data/list/event-2.jsonld", - "name": "Workshop3", - "date": "2020-05-10", - "year": 2020, - "seats": 2, - "place":"Opéra", - "city":"", - "permissions": [] - }, - { - "@id": "/examples/data/list/event-3.jsonld", - "name": "Workshop1", - "date": "2017-05-10", - "year": 2017, - "seats": 23, - "place":"Opéra3", - "city":"", - "permissions": [] - }, - { - "@id": "/examples/data/list/event-4.jsonld", - "name": "Workshop", - "date": "2015-05-10", - "year": 2015, - "seats": 2, - "place":"Opéra2", - "city":"", - "permissions": [] - }, - { - "@id": "/examples/data/list/event-5.jsonld", - "name": "Réunion d'information", - "date": "2020-07-10", - "year": 2020, - "seats": 36, - "place":"Couvent des jacobins", - "city":"Rennes", - "permissions": [] - }, - { - "@id": "/examples/data/list/event-6.jsonld", - "name": "Assemblée générale", - "date": "2020-05-10", - "year": 2019, - "seats": 5, - "place":"", - "city":"Marseille", - "permissions": [] - } - ], - "@id": "/examples/data/list/event-5.jsonld", - "@context": "https://cdn.startinblox.com/owl/context.jsonld" + "@type": "ldp:Container", + "ldp:contains": [ + { + "@id": "/examples/data/list/event-1.jsonld", + "name": "Coliving", + "date": "2020-07-09", + "year": 2020, + "seats": 12, + "place": "", + "city": "", + "permissions": [] + }, + { + "@id": "/examples/data/list/event-2.jsonld", + "name": "Workshop3", + "date": "2020-05-10", + "year": 2020, + "seats": 2, + "place": "Opéra", + "city": "", + "permissions": [] + }, + { + "@id": "/examples/data/list/event-3.jsonld", + "name": "Workshop1", + "date": "2017-05-10", + "year": 2017, + "seats": 23, + "place": "Opéra3", + "city": "", + "permissions": [] + }, + { + "@id": "/examples/data/list/event-4.jsonld", + "name": "Workshop", + "date": "2015-05-10", + "year": 2015, + "seats": 2, + "place": "Opéra2", + "city": "", + "permissions": [] + }, + { + "@id": "/examples/data/list/event-5.jsonld", + "name": "Réunion d'information", + "date": "2020-07-10", + "year": 2020, + "seats": 36, + "place": "Couvent des jacobins", + "city": "Rennes", + "permissions": [] + }, + { + "@id": "/examples/data/list/event-6.jsonld", + "name": "Assemblée générale", + "date": "2020-05-10", + "year": 2019, + "seats": 5, + "place": "", + "city": "Marseille", + "permissions": [] + } + ], + "@id": "/examples/data/list/event-5.jsonld", + "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/list/event-empty.jsonld b/examples/data/list/event-empty.jsonld index d35de149..c952e62f 100644 --- a/examples/data/list/event-empty.jsonld +++ b/examples/data/list/event-empty.jsonld @@ -1,12 +1,12 @@ { - "@id": "/examples/data/list/event-empty.jsonld", - "name": "", - "date": "", - "seats": 0, - "description": "", - "contact": { - "@id": "/examples/data/list/user-1.jsonld" - }, - "permissions": [], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" + "@id": "/examples/data/list/event-empty.jsonld", + "name": "", + "date": "", + "seats": 0, + "description": "", + "contact": { + "@id": "/examples/data/list/user-1.jsonld" + }, + "permissions": [], + "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/list/events.jsonld b/examples/data/list/events.jsonld index 85d9a78b..453a9df4 100644 --- a/examples/data/list/events.jsonld +++ b/examples/data/list/events.jsonld @@ -1,43 +1,43 @@ { - "@type": "ldp:Container", - "ldp:contains": [ - { - "@id": "/examples/data/list/event-1.jsonld", - "name": "Coliving", - "date": "2020-07-09", - "seats": 12, - "place":"", - "city":"", - "permissions": [] - }, - { - "@id": "/examples/data/list/event-2.jsonld", - "name": "Workshop", - "date": "2020-05-10", - "seats": 2, - "place":"Opéra", - "city":"", - "permissions": [] - }, - { - "@id": "/examples/data/list/event-3.jsonld", - "name": "Réunion d'information", - "date": "2020-07-10", - "seats": 36, - "place":"Couvent des jacobins", - "city":"Rennes", - "permissions": [] - }, - { - "@id": "/examples/data/list/event-4.jsonld", - "name": "Assemblée générale", - "date": "2020-05-10", - "seats": 5, - "place":"", - "city":"Marseille", - "permissions": [] - } - ], - "@id": "/examples/data/list/events.jsonld", - "@context": "https://cdn.startinblox.com/owl/context.jsonld" + "@type": "ldp:Container", + "ldp:contains": [ + { + "@id": "/examples/data/list/event-1.jsonld", + "name": "Coliving", + "date": "2020-07-09", + "seats": 12, + "place": "", + "city": "", + "permissions": [] + }, + { + "@id": "/examples/data/list/event-2.jsonld", + "name": "Workshop", + "date": "2020-05-10", + "seats": 2, + "place": "Opéra", + "city": "", + "permissions": [] + }, + { + "@id": "/examples/data/list/event-3.jsonld", + "name": "Réunion d'information", + "date": "2020-07-10", + "seats": 36, + "place": "Couvent des jacobins", + "city": "Rennes", + "permissions": [] + }, + { + "@id": "/examples/data/list/event-4.jsonld", + "name": "Assemblée générale", + "date": "2020-05-10", + "seats": 5, + "place": "", + "city": "Marseille", + "permissions": [] + } + ], + "@id": "/examples/data/list/events.jsonld", + "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/list/group-3.jsonld b/examples/data/list/group-3.jsonld index ba821d13..103d8374 100644 --- a/examples/data/list/group-3.jsonld +++ b/examples/data/list/group-3.jsonld @@ -1,50 +1,50 @@ { "name": "LDP_circle_members_1", "members": [ - { - "@id": "/examples/data/list/user-2.jsonld", - "@type": "foaf:user", - "name": "Benoit Alessandroni", - "email": "benoit@toto.com", - "last_name": "Alessandroni", - "first_name": "Benoit", - "@context": { - "get_full_name": "rdfs:label" - } - }, - { - "@id": "/examples/data/list/user-1.jsonld", - "@type": "foaf:user", - "name": "Blaise Pascal", - "email": "blaise@toto.com", - "last_name": "Pascal", - "first_name": "Blaise", - "@context": { - "get_full_name": "rdfs:label" - } - }, - { - "@id": "/examples/data/list/user-3.jsonld", - "@type": "foaf:user", - "name": "Vitali Klitschko", - "email": "blaise@toto.com", - "last_name": "Klitschko", - "first_name": "Vitali", - "@context": { - "get_full_name": "rdfs:label" - } - }, - { - "@id": "/examples/data/list/user-4.jsonld", - "@type": "foaf:user", - "name": "Eric Cantona", - "email": "cantona@toto.com", - "last_name": "Cantona", - "first_name": "Eric", - "@context": { - "get_full_name": "rdfs:label" - } + { + "@id": "/examples/data/list/user-2.jsonld", + "@type": "foaf:user", + "name": "Benoit Alessandroni", + "email": "benoit@toto.com", + "last_name": "Alessandroni", + "first_name": "Benoit", + "@context": { + "get_full_name": "rdfs:label" + } + }, + { + "@id": "/examples/data/list/user-1.jsonld", + "@type": "foaf:user", + "name": "Blaise Pascal", + "email": "blaise@toto.com", + "last_name": "Pascal", + "first_name": "Blaise", + "@context": { + "get_full_name": "rdfs:label" + } + }, + { + "@id": "/examples/data/list/user-3.jsonld", + "@type": "foaf:user", + "name": "Vitali Klitschko", + "email": "blaise@toto.com", + "last_name": "Klitschko", + "first_name": "Vitali", + "@context": { + "get_full_name": "rdfs:label" + } + }, + { + "@id": "/examples/data/list/user-4.jsonld", + "@type": "foaf:user", + "name": "Eric Cantona", + "email": "cantona@toto.com", + "last_name": "Cantona", + "first_name": "Eric", + "@context": { + "get_full_name": "rdfs:label" } + } ], "events": { "@type": "ldp:Container", @@ -55,8 +55,8 @@ "name": "Coliving", "date": "2020-07-09", "seats": 12, - "place":"", - "city":"", + "place": "", + "city": "", "permissions": [] }, { @@ -64,8 +64,8 @@ "name": "Workshop", "date": "2020-05-10", "seats": 2, - "place":"Opéra", - "city":"", + "place": "Opéra", + "city": "", "permissions": [] } ] @@ -77,7 +77,5 @@ "admin_circle": null, "@id": "/examples/data/list/group-3.jsonld", "@type": "foaf:Group", - "@context": [ - "https://cdn.startinblox.com/owl/context.jsonld" - ] + "@context": ["https://cdn.startinblox.com/owl/context.jsonld"] } diff --git a/examples/data/list/job-1.jsonld b/examples/data/list/job-1.jsonld index a256e69b..2c493c67 100644 --- a/examples/data/list/job-1.jsonld +++ b/examples/data/list/job-1.jsonld @@ -11,11 +11,9 @@ }, { "@id": "/examples/data/list/skill-4.jsonld" - } + } ] }, - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/profile-1.jsonld b/examples/data/list/profile-1.jsonld index e00d67bf..7074cc28 100644 --- a/examples/data/list/profile-1.jsonld +++ b/examples/data/list/profile-1.jsonld @@ -10,8 +10,6 @@ "city": "Paris", "phone": "06-03-23-98-23", "website": "www.startinblox.com", - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/profile-2.jsonld b/examples/data/list/profile-2.jsonld index 558806b3..8c6dcee1 100644 --- a/examples/data/list/profile-2.jsonld +++ b/examples/data/list/profile-2.jsonld @@ -10,8 +10,6 @@ "city": "Paris", "phone": "", "website": "", - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/profile-3.jsonld b/examples/data/list/profile-3.jsonld index 4ec2e704..b5520a0a 100644 --- a/examples/data/list/profile-3.jsonld +++ b/examples/data/list/profile-3.jsonld @@ -10,8 +10,6 @@ "city": "Rennes", "phone": "", "website": "", - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/profile-4.jsonld b/examples/data/list/profile-4.jsonld index c51f3cb3..850f2999 100644 --- a/examples/data/list/profile-4.jsonld +++ b/examples/data/list/profile-4.jsonld @@ -10,8 +10,6 @@ "city": "", "phone": "", "website": "", - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/profile-5.jsonld b/examples/data/list/profile-5.jsonld index cf52fc44..67be8b94 100644 --- a/examples/data/list/profile-5.jsonld +++ b/examples/data/list/profile-5.jsonld @@ -10,8 +10,6 @@ "city": "", "phone": "", "website": "[my site](http://drawing.garden/)", - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/skill-1.jsonld b/examples/data/list/skill-1.jsonld index 779d8d67..efee0300 100644 --- a/examples/data/list/skill-1.jsonld +++ b/examples/data/list/skill-1.jsonld @@ -2,11 +2,6 @@ "@id": "/examples/data/list/skill-1.jsonld", "name": "HTML", "@type": "hd:skill", - "permissions": [ - "view", - "change", - "control", - "delete" - ], + "permissions": ["view", "change", "control", "delete"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/skill-2.jsonld b/examples/data/list/skill-2.jsonld index 53f54658..074f19e2 100644 --- a/examples/data/list/skill-2.jsonld +++ b/examples/data/list/skill-2.jsonld @@ -20,11 +20,6 @@ } ] }, - "permissions": [ - "view", - "change", - "control", - "delete" - ], + "permissions": ["view", "change", "control", "delete"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/skill-3.jsonld b/examples/data/list/skill-3.jsonld index e13029aa..492846fd 100644 --- a/examples/data/list/skill-3.jsonld +++ b/examples/data/list/skill-3.jsonld @@ -20,11 +20,6 @@ } ] }, - "permissions": [ - "view", - "change", - "control", - "delete" - ], + "permissions": ["view", "change", "control", "delete"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/skill-4.jsonld b/examples/data/list/skill-4.jsonld index 718aceeb..97a2298c 100644 --- a/examples/data/list/skill-4.jsonld +++ b/examples/data/list/skill-4.jsonld @@ -2,11 +2,6 @@ "@id": "/examples/data/list/skill-4.jsonld", "name": "DevOps", "@type": "hd:skill", - "permissions": [ - "view", - "change", - "control", - "delete" - ], + "permissions": ["view", "change", "control", "delete"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/skill-5.jsonld b/examples/data/list/skill-5.jsonld index 536ff49c..8264f8cd 100644 --- a/examples/data/list/skill-5.jsonld +++ b/examples/data/list/skill-5.jsonld @@ -2,11 +2,6 @@ "@id": "/examples/data/list/skill-5.jsonld", "name": "PHP", "@type": "hd:skill", - "permissions": [ - "view", - "change", - "control", - "delete" - ], + "permissions": ["view", "change", "control", "delete"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/skill-6.jsonld b/examples/data/list/skill-6.jsonld index f0e706eb..158dee7c 100644 --- a/examples/data/list/skill-6.jsonld +++ b/examples/data/list/skill-6.jsonld @@ -2,11 +2,6 @@ "@id": "/examples/data/list/skill-6.jsonld", "name": "Git", "@type": "hd:skill", - "permissions": [ - "view", - "change", - "control", - "delete" - ], + "permissions": ["view", "change", "control", "delete"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/skill-7.jsonld b/examples/data/list/skill-7.jsonld index 9f5f34b1..9cf2d4aa 100644 --- a/examples/data/list/skill-7.jsonld +++ b/examples/data/list/skill-7.jsonld @@ -2,11 +2,6 @@ "@id": "/examples/data/list/skill-7.jsonld", "name": "Python", "@type": "hd:skill", - "permissions": [ - "view", - "change", - "control", - "delete" - ], + "permissions": ["view", "change", "control", "delete"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/skill-8.jsonld b/examples/data/list/skill-8.jsonld index 077b8440..fc771b98 100644 --- a/examples/data/list/skill-8.jsonld +++ b/examples/data/list/skill-8.jsonld @@ -2,11 +2,6 @@ "@id": "/examples/data/list/skill-8.jsonld", "name": "Node", "@type": "hd:skill", - "permissions": [ - "view", - "change", - "control", - "delete" - ], + "permissions": ["view", "change", "control", "delete"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/skills.jsonld b/examples/data/list/skills.jsonld index fdc0d5b5..2ab8fccb 100644 --- a/examples/data/list/skills.jsonld +++ b/examples/data/list/skills.jsonld @@ -7,8 +7,7 @@ "name": "HTML", "order": 1, "@type": "hd:skill", - "permissions": [ - ] + "permissions": [] }, { "@id": "/examples/data/list/skill-2.jsonld", @@ -21,69 +20,44 @@ "name": "Javascript", "order": 2, "@type": "hd:skill", - "permissions": [ - ] + "permissions": [] }, { "@id": "/examples/data/list/skill-4.jsonld", "name": "DevOps", "order": 10, "@type": "hd:skill", - "permissions": [ - "view", - "change", - "control", - "delete" - ] + "permissions": ["view", "change", "control", "delete"] }, { "@id": "/examples/data/list/skill-5.jsonld", "name": "PHP", "order": 15, "@type": "hd:skill", - "permissions": [ - ] + "permissions": [] }, { "@id": "/examples/data/list/skill-6.jsonld", "name": "Git", "order": 20, "@type": "hd:skill", - "permissions": [ - "view", - "change", - "control", - "delete" - ] + "permissions": ["view", "change", "control", "delete"] }, { "@id": "/examples/data/list/skill-7.jsonld", "name": "Python", "order": 27, "@type": "hd:skill", - "permissions": [ - "view", - "change", - "control", - "delete" - ] + "permissions": ["view", "change", "control", "delete"] }, { "@id": "/examples/data/list/skill-8.jsonld", "name": "Node", "order": 30, "@type": "hd:skill", - "permissions": [ - "view", - "change", - "control", - "delete" - ] + "permissions": ["view", "change", "control", "delete"] } ], - "permissions": [ - "view", - "add" - ], + "permissions": ["view", "add"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/starwars-origin.jsonld b/examples/data/list/starwars-origin.jsonld index 05e14fcc..fb422c74 100644 --- a/examples/data/list/starwars-origin.jsonld +++ b/examples/data/list/starwars-origin.jsonld @@ -4,14 +4,18 @@ "@type": "hd:film", "ebu:originalTitle": "Star Wars", "characters": { - "@id": "/examples/data/list/local.jsonld", - "@type": "ldp:Container", - "ldp:contains": [ - { "@id": "/examples/data/list/examples/data/list/darth-vader.json" }, - { "@id": "/examples/data/list/examples/data/list/chewbacca.jsonld", "name": "tata" }, - { - "@id": "/examples/data/list/examples/data/list/hansolo.jsonld", "name": "trotro" - } - ] + "@id": "/examples/data/list/local.jsonld", + "@type": "ldp:Container", + "ldp:contains": [ + { "@id": "/examples/data/list/examples/data/list/darth-vader.json" }, + { + "@id": "/examples/data/list/examples/data/list/chewbacca.jsonld", + "name": "tata" + }, + { + "@id": "/examples/data/list/examples/data/list/hansolo.jsonld", + "name": "trotro" + } + ] } -} \ No newline at end of file +} diff --git a/examples/data/list/starwars.jsonld b/examples/data/list/starwars.jsonld index 8a63d485..b36632a3 100644 --- a/examples/data/list/starwars.jsonld +++ b/examples/data/list/starwars.jsonld @@ -14,5 +14,5 @@ "name": "Han solo" } ], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file + "@context": "https://cdn.startinblox.com/owl/context.jsonld" +} diff --git a/examples/data/list/types.jsonld b/examples/data/list/types.jsonld index 7f18cb03..a3455fbf 100644 --- a/examples/data/list/types.jsonld +++ b/examples/data/list/types.jsonld @@ -1,10 +1,7 @@ { "@context": "https://colibris.social/context.json", "id": "https://colibris.social/types", - "type": [ - "ldp:Container", - "ldp:BasicContainer" - ], + "type": ["ldp:Container", "ldp:BasicContainer"], "ldp:contains": [ { "id": "https://colibris.social/types/camping", diff --git a/examples/data/list/universite.jsonld b/examples/data/list/universite.jsonld index 02156fb5..9508e428 100644 --- a/examples/data/list/universite.jsonld +++ b/examples/data/list/universite.jsonld @@ -1,18 +1,11 @@ { "@context": "https://colibris.social/context.json", "id": "/examples/data/list/universite.jsonld", - "type": [ - "ldp:Container", - "ldp:BasicContainer" - ], + "type": ["ldp:Container", "ldp:BasicContainer"], "ldp:contains": [ { "id": "/examples/data/list/universite/courses.jsonld", - "type": [ - "ldp:Container", - "ldp:BasicContainer", - "ldp:Resource" - ] + "type": ["ldp:Container", "ldp:BasicContainer", "ldp:Resource"] } ] } diff --git a/examples/data/list/universite/courses.jsonld b/examples/data/list/universite/courses.jsonld index 56eb50a0..ffff6b67 100644 --- a/examples/data/list/universite/courses.jsonld +++ b/examples/data/list/universite/courses.jsonld @@ -1,10 +1,7 @@ { "@context": "https://cdn.startinblox.com/owl/context.jsonld", "id": "/examples/data/list/universite/courses.jsonld", - "type": [ - "ldp:Container", - "ldp:BasicContainer" - ], + "type": ["ldp:Container", "ldp:BasicContainer"], "ldp:contains": [ { "id": "universite/courses/concevoir-une-oasis-partie-2-la-creation-du-collectif-0", diff --git a/examples/data/list/user-1-skills.jsonld b/examples/data/list/user-1-skills.jsonld index 8db9211c..1708ecaa 100644 --- a/examples/data/list/user-1-skills.jsonld +++ b/examples/data/list/user-1-skills.jsonld @@ -9,8 +9,6 @@ "@id": "/examples/data/list/skill-3.jsonld" } ], - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/user-1.jsonld b/examples/data/list/user-1.jsonld index 20b6d136..f2f7ab94 100644 --- a/examples/data/list/user-1.jsonld +++ b/examples/data/list/user-1.jsonld @@ -17,9 +17,7 @@ "@id": "/examples/data/list/skill-3.jsonld" } ], - "permissions": [ - "view" - ] + "permissions": ["view"] }, "job": { "@id": "/examples/data/list/job-1.jsonld" @@ -28,8 +26,6 @@ "@id": "/examples/data/list/profile-1.jsonld" }, "@type": "foaf:user", - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/user-2-skills.jsonld b/examples/data/list/user-2-skills.jsonld index 67f2ee4a..0cac47d5 100644 --- a/examples/data/list/user-2-skills.jsonld +++ b/examples/data/list/user-2-skills.jsonld @@ -6,8 +6,6 @@ "@id": "/examples/data/list/skill-1.jsonld" } ], - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/user-2.jsonld b/examples/data/list/user-2.jsonld index 17586e2b..499a5a0b 100644 --- a/examples/data/list/user-2.jsonld +++ b/examples/data/list/user-2.jsonld @@ -14,16 +14,12 @@ "@id": "/examples/data/list/skill-1.jsonld" } ], - "permissions": [ - "view" - ] + "permissions": ["view"] }, "profile": { "@id": "/examples/data/list/profile-2.jsonld" }, "@type": "foaf:user", - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/user-3-skills.jsonld b/examples/data/list/user-3-skills.jsonld index ffe5dbcc..af30fae8 100644 --- a/examples/data/list/user-3-skills.jsonld +++ b/examples/data/list/user-3-skills.jsonld @@ -1,11 +1,7 @@ { "@id": "/examples/data/list/user-3-skills.jsonld", "@type": "ldp:Container", - "ldp:contains": [ - - ], - "permissions": [ - "view" - ], + "ldp:contains": [], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/user-3.jsonld b/examples/data/list/user-3.jsonld index 31b4e6ba..146fd0f0 100644 --- a/examples/data/list/user-3.jsonld +++ b/examples/data/list/user-3.jsonld @@ -9,19 +9,13 @@ "skills": { "@id": "/examples/data/list/user-3-skills.jsonld", "@type": "ldp:Container", - "ldp:contains": [ - - ], - "permissions": [ - "view" - ] + "ldp:contains": [], + "permissions": ["view"] }, "profile": { "@id": "/examples/data/list/profile-3.jsonld" }, "@type": "foaf:user", - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/user-4-skills.jsonld b/examples/data/list/user-4-skills.jsonld index 078d534e..37fbd60c 100644 --- a/examples/data/list/user-4-skills.jsonld +++ b/examples/data/list/user-4-skills.jsonld @@ -12,8 +12,6 @@ "@id": "/examples/data/list/skill-4.jsonld" } ], - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/user-4.jsonld b/examples/data/list/user-4.jsonld index d18fcd9d..ccd661a4 100644 --- a/examples/data/list/user-4.jsonld +++ b/examples/data/list/user-4.jsonld @@ -20,16 +20,12 @@ "@id": "/examples/data/list/skill-4.jsonld" } ], - "permissions": [ - "view" - ] + "permissions": ["view"] }, "profile": { "@id": "/examples/data/list/profile-4.jsonld" }, "@type": "foaf:user", - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/user-5-skills.jsonld b/examples/data/list/user-5-skills.jsonld index 737dd301..a437071c 100644 --- a/examples/data/list/user-5-skills.jsonld +++ b/examples/data/list/user-5-skills.jsonld @@ -12,8 +12,6 @@ "@id": "/examples/data/list/skill-8.jsonld" } ], - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/user-5.jsonld b/examples/data/list/user-5.jsonld index ceffd4da..658c1a7a 100644 --- a/examples/data/list/user-5.jsonld +++ b/examples/data/list/user-5.jsonld @@ -20,16 +20,12 @@ "@id": "/examples/data/list/skill-8.jsonld" } ], - "permissions": [ - "view" - ] + "permissions": ["view"] }, "profile": { "@id": "/examples/data/list/profile-5.jsonld" }, "@type": "foaf:user", - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/users-group1.jsonld b/examples/data/list/users-group1.jsonld index de9fa3b3..9e6a188f 100644 --- a/examples/data/list/users-group1.jsonld +++ b/examples/data/list/users-group1.jsonld @@ -22,17 +22,13 @@ "@id": "/examples/data/list/skill-3.jsonld" } ], - "permissions": [ - "view" - ] + "permissions": ["view"] }, "profile": { "@id": "/examples/data/list/profile-1.jsonld" }, "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/user-2.jsonld", @@ -51,17 +47,13 @@ "@id": "/examples/data/list/skill-1.jsonld" } ], - "permissions": [ - "view" - ] + "permissions": ["view"] }, "profile": { "@id": "/examples/data/list/profile-2.jsonld" }, "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/user-3.jsonld", @@ -75,24 +67,16 @@ "skills": { "@id": "/examples/data/list/user-3-skills.jsonld", "@type": "ldp:Container", - "ldp:contains": [ - - ], - "permissions": [ - "view" - ] + "ldp:contains": [], + "permissions": ["view"] }, "profile": { "@id": "/examples/data/list/profile-3.jsonld" }, "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] } ], - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/users-group2.jsonld b/examples/data/list/users-group2.jsonld index 9aeb2bae..acd5eedc 100644 --- a/examples/data/list/users-group2.jsonld +++ b/examples/data/list/users-group2.jsonld @@ -19,17 +19,13 @@ "@id": "/examples/data/list/skill-1.jsonld" } ], - "permissions": [ - "view" - ] + "permissions": ["view"] }, "profile": { "@id": "/examples/data/list/profile-2.jsonld" }, "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/user-4.jsonld", @@ -54,17 +50,13 @@ "@id": "/examples/data/list/skill-4.jsonld" } ], - "permissions": [ - "view" - ] + "permissions": ["view"] }, "profile": { "@id": "/examples/data/list/profile-4.jsonld" }, "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/user-5.jsonld", @@ -88,21 +80,15 @@ "@id": "/examples/data/list/skill-8.jsonld" } ], - "permissions": [ - "view" - ] + "permissions": ["view"] }, "profile": { "@id": "/examples/data/list/profile-5.jsonld" }, "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] } ], - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/users-long.jsonld b/examples/data/list/users-long.jsonld index 82e62771..f286a947 100644 --- a/examples/data/list/users-long.jsonld +++ b/examples/data/list/users-long.jsonld @@ -1,9 +1,7 @@ { "@id": "/examples/data/list/users-long.jsonld", "@type": "ldp:Container", - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld", "ldp:contains": [ { @@ -14,9 +12,7 @@ "username": "mayer.glenn", "email": "mayer.glenn@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-1.jsonld", @@ -26,9 +22,7 @@ "username": "santiago.fowler", "email": "santiago.fowler@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-2.jsonld", @@ -38,9 +32,7 @@ "username": "imelda.kemp", "email": "imelda.kemp@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-3.jsonld", @@ -50,9 +42,7 @@ "username": "tillman.mcmahon", "email": "tillman.mcmahon@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-4.jsonld", @@ -62,9 +52,7 @@ "username": "torres.henry", "email": "torres.henry@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-5.jsonld", @@ -74,9 +62,7 @@ "username": "ines.head", "email": "ines.head@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-6.jsonld", @@ -86,9 +72,7 @@ "username": "cotton.sullivan", "email": "cotton.sullivan@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-7.jsonld", @@ -98,9 +82,7 @@ "username": "nelda.armstrong", "email": "nelda.armstrong@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-8.jsonld", @@ -110,9 +92,7 @@ "username": "marianne.gentry", "email": "marianne.gentry@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-9.jsonld", @@ -122,9 +102,7 @@ "username": "sweet.petersen", "email": "sweet.petersen@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-10.jsonld", @@ -134,9 +112,7 @@ "username": "henry.noble", "email": "henry.noble@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-11.jsonld", @@ -146,9 +122,7 @@ "username": "rhodes.michael", "email": "rhodes.michael@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-12.jsonld", @@ -158,9 +132,7 @@ "username": "browning.sherman", "email": "browning.sherman@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-13.jsonld", @@ -170,9 +142,7 @@ "username": "ellen.walter", "email": "ellen.walter@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-14.jsonld", @@ -182,9 +152,7 @@ "username": "jolene.winters", "email": "jolene.winters@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-15.jsonld", @@ -194,9 +162,7 @@ "username": "benton.powell", "email": "benton.powell@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-16.jsonld", @@ -206,9 +172,7 @@ "username": "lott.franklin", "email": "lott.franklin@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-17.jsonld", @@ -218,9 +182,7 @@ "username": "noble.ramirez", "email": "noble.ramirez@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-18.jsonld", @@ -230,9 +192,7 @@ "username": "case.gillespie", "email": "case.gillespie@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-19.jsonld", @@ -242,9 +202,7 @@ "username": "oneill.frank", "email": "oneill.frank@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-20.jsonld", @@ -254,9 +212,7 @@ "username": "francesca.tanner", "email": "francesca.tanner@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-21.jsonld", @@ -266,9 +222,7 @@ "username": "shauna.floyd", "email": "shauna.floyd@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-22.jsonld", @@ -278,9 +232,7 @@ "username": "michelle.terrell", "email": "michelle.terrell@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-23.jsonld", @@ -290,9 +242,7 @@ "username": "carmella.bennett", "email": "carmella.bennett@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-24.jsonld", @@ -302,9 +252,7 @@ "username": "levine.morrison", "email": "levine.morrison@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-25.jsonld", @@ -314,9 +262,7 @@ "username": "janice.lane", "email": "janice.lane@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-26.jsonld", @@ -326,9 +272,7 @@ "username": "woods.clay", "email": "woods.clay@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-27.jsonld", @@ -338,9 +282,7 @@ "username": "anna.abbott", "email": "anna.abbott@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-28.jsonld", @@ -350,9 +292,7 @@ "username": "atkins.levine", "email": "atkins.levine@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-29.jsonld", @@ -362,9 +302,7 @@ "username": "tiffany.dunn", "email": "tiffany.dunn@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-30.jsonld", @@ -374,9 +312,7 @@ "username": "valarie.lindsay", "email": "valarie.lindsay@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-31.jsonld", @@ -386,9 +322,7 @@ "username": "finley.solis", "email": "finley.solis@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-32.jsonld", @@ -398,9 +332,7 @@ "username": "mclaughlin.wagner", "email": "mclaughlin.wagner@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-33.jsonld", @@ -410,9 +342,7 @@ "username": "roslyn.hyde", "email": "roslyn.hyde@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-34.jsonld", @@ -422,9 +352,7 @@ "username": "rosetta.craig", "email": "rosetta.craig@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-35.jsonld", @@ -434,9 +362,7 @@ "username": "geraldine.waters", "email": "geraldine.waters@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-36.jsonld", @@ -446,9 +372,7 @@ "username": "zamora.ellison", "email": "zamora.ellison@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-37.jsonld", @@ -458,9 +382,7 @@ "username": "eileen.cantu", "email": "eileen.cantu@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-38.jsonld", @@ -470,9 +392,7 @@ "username": "lynette.oconnor", "email": "lynette.oconnor@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-39.jsonld", @@ -482,9 +402,7 @@ "username": "maritza.middleton", "email": "maritza.middleton@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-40.jsonld", @@ -494,9 +412,7 @@ "username": "norman.peters", "email": "norman.peters@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-41.jsonld", @@ -506,9 +422,7 @@ "username": "lane.navarro", "email": "lane.navarro@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-42.jsonld", @@ -518,9 +432,7 @@ "username": "oliver.fulton", "email": "oliver.fulton@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-43.jsonld", @@ -530,9 +442,7 @@ "username": "dale.bishop", "email": "dale.bishop@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-44.jsonld", @@ -542,9 +452,7 @@ "username": "wise.vazquez", "email": "wise.vazquez@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-45.jsonld", @@ -554,9 +462,7 @@ "username": "gilliam.moran", "email": "gilliam.moran@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-46.jsonld", @@ -566,9 +472,7 @@ "username": "ellison.wilson", "email": "ellison.wilson@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-47.jsonld", @@ -578,9 +482,7 @@ "username": "fanny.sandoval", "email": "fanny.sandoval@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-48.jsonld", @@ -590,9 +492,7 @@ "username": "hale.macdonald", "email": "hale.macdonald@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-49.jsonld", @@ -602,9 +502,7 @@ "username": "riley.mcfarland", "email": "riley.mcfarland@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-50.jsonld", @@ -614,9 +512,7 @@ "username": "prince.wilkerson", "email": "prince.wilkerson@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-51.jsonld", @@ -626,9 +522,7 @@ "username": "barnett.klein", "email": "barnett.klein@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-52.jsonld", @@ -638,9 +532,7 @@ "username": "amy.collins", "email": "amy.collins@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-53.jsonld", @@ -650,9 +542,7 @@ "username": "wells.grant", "email": "wells.grant@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-54.jsonld", @@ -662,9 +552,7 @@ "username": "melton.peterson", "email": "melton.peterson@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-55.jsonld", @@ -674,9 +562,7 @@ "username": "davenport.townsend", "email": "davenport.townsend@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-56.jsonld", @@ -686,9 +572,7 @@ "username": "mayo.flynn", "email": "mayo.flynn@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-57.jsonld", @@ -698,9 +582,7 @@ "username": "latoya.haynes", "email": "latoya.haynes@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-58.jsonld", @@ -710,9 +592,7 @@ "username": "catherine.parrish", "email": "catherine.parrish@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-59.jsonld", @@ -722,9 +602,7 @@ "username": "bernadette.roman", "email": "bernadette.roman@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-60.jsonld", @@ -734,9 +612,7 @@ "username": "jeanne.rosa", "email": "jeanne.rosa@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-61.jsonld", @@ -746,9 +622,7 @@ "username": "ward.cunningham", "email": "ward.cunningham@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-62.jsonld", @@ -758,9 +632,7 @@ "username": "melba.nelson", "email": "melba.nelson@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-63.jsonld", @@ -770,9 +642,7 @@ "username": "johnston.ashley", "email": "johnston.ashley@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-64.jsonld", @@ -782,9 +652,7 @@ "username": "mavis.sellers", "email": "mavis.sellers@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-65.jsonld", @@ -794,9 +662,7 @@ "username": "veronica.rollins", "email": "veronica.rollins@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-66.jsonld", @@ -806,9 +672,7 @@ "username": "renee.melendez", "email": "renee.melendez@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-67.jsonld", @@ -818,9 +682,7 @@ "username": "mccarty.gates", "email": "mccarty.gates@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-68.jsonld", @@ -830,9 +692,7 @@ "username": "day.rios", "email": "day.rios@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-69.jsonld", @@ -842,9 +702,7 @@ "username": "frye.johns", "email": "frye.johns@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-70.jsonld", @@ -854,9 +712,7 @@ "username": "cheryl.wilkinson", "email": "cheryl.wilkinson@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-71.jsonld", @@ -866,9 +722,7 @@ "username": "munoz.douglas", "email": "munoz.douglas@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-72.jsonld", @@ -878,9 +732,7 @@ "username": "debra.cook", "email": "debra.cook@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-73.jsonld", @@ -890,9 +742,7 @@ "username": "schneider.villarreal", "email": "schneider.villarreal@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-74.jsonld", @@ -902,9 +752,7 @@ "username": "hayes.holloway", "email": "hayes.holloway@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-75.jsonld", @@ -914,9 +762,7 @@ "username": "buck.velazquez", "email": "buck.velazquez@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-76.jsonld", @@ -926,9 +772,7 @@ "username": "aida.pugh", "email": "aida.pugh@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-77.jsonld", @@ -938,9 +782,7 @@ "username": "pamela.olsen", "email": "pamela.olsen@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-78.jsonld", @@ -950,9 +792,7 @@ "username": "trudy.lucas", "email": "trudy.lucas@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-79.jsonld", @@ -962,9 +802,7 @@ "username": "madge.casey", "email": "madge.casey@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-80.jsonld", @@ -974,9 +812,7 @@ "username": "nicole.palmer", "email": "nicole.palmer@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-81.jsonld", @@ -986,9 +822,7 @@ "username": "hopper.harrell", "email": "hopper.harrell@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-82.jsonld", @@ -998,9 +832,7 @@ "username": "chelsea.kennedy", "email": "chelsea.kennedy@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-83.jsonld", @@ -1010,9 +842,7 @@ "username": "townsend.morin", "email": "townsend.morin@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-84.jsonld", @@ -1022,9 +852,7 @@ "username": "valenzuela.herring", "email": "valenzuela.herring@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-85.jsonld", @@ -1034,9 +862,7 @@ "username": "iris.durham", "email": "iris.durham@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-86.jsonld", @@ -1046,9 +872,7 @@ "username": "guerrero.wooten", "email": "guerrero.wooten@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] } ] -} \ No newline at end of file +} diff --git a/examples/data/list/users-mocked.jsonld b/examples/data/list/users-mocked.jsonld index 66976ac6..d98da4bf 100644 --- a/examples/data/list/users-mocked.jsonld +++ b/examples/data/list/users-mocked.jsonld @@ -1,9 +1,7 @@ { "@id": "/mock/users.jsonld", "@type": "ldp:Container", - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld", "ldp:contains": [ { @@ -14,9 +12,7 @@ "username": "mayer.glenn", "email": "mayer.glenn@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-1.jsonld", @@ -26,9 +22,7 @@ "username": "santiago.fowler", "email": "santiago.fowler@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-2.jsonld", @@ -38,9 +32,7 @@ "username": "imelda.kemp", "email": "imelda.kemp@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-3.jsonld", @@ -50,9 +42,7 @@ "username": "tillman.mcmahon", "email": "tillman.mcmahon@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-4.jsonld", @@ -62,9 +52,7 @@ "username": "torres.henry", "email": "torres.henry@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-5.jsonld", @@ -74,9 +62,7 @@ "username": "ines.head", "email": "ines.head@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-6.jsonld", @@ -86,9 +72,7 @@ "username": "cotton.sullivan", "email": "cotton.sullivan@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-7.jsonld", @@ -98,9 +82,7 @@ "username": "nelda.armstrong", "email": "nelda.armstrong@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-8.jsonld", @@ -110,9 +92,7 @@ "username": "marianne.gentry", "email": "marianne.gentry@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-9.jsonld", @@ -122,9 +102,7 @@ "username": "sweet.petersen", "email": "sweet.petersen@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-10.jsonld", @@ -134,9 +112,7 @@ "username": "henry.noble", "email": "henry.noble@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-11.jsonld", @@ -146,9 +122,7 @@ "username": "rhodes.michael", "email": "rhodes.michael@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-12.jsonld", @@ -158,9 +132,7 @@ "username": "browning.sherman", "email": "browning.sherman@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-13.jsonld", @@ -170,9 +142,7 @@ "username": "ellen.walter", "email": "ellen.walter@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-14.jsonld", @@ -182,9 +152,7 @@ "username": "jolene.winters", "email": "jolene.winters@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-15.jsonld", @@ -194,9 +162,7 @@ "username": "benton.powell", "email": "benton.powell@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-16.jsonld", @@ -206,9 +172,7 @@ "username": "lott.franklin", "email": "lott.franklin@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-17.jsonld", @@ -218,9 +182,7 @@ "username": "noble.ramirez", "email": "noble.ramirez@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-18.jsonld", @@ -230,9 +192,7 @@ "username": "case.gillespie", "email": "case.gillespie@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-19.jsonld", @@ -242,9 +202,7 @@ "username": "oneill.frank", "email": "oneill.frank@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-20.jsonld", @@ -254,9 +212,7 @@ "username": "francesca.tanner", "email": "francesca.tanner@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-21.jsonld", @@ -266,9 +222,7 @@ "username": "shauna.floyd", "email": "shauna.floyd@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-22.jsonld", @@ -278,9 +232,7 @@ "username": "michelle.terrell", "email": "michelle.terrell@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-23.jsonld", @@ -290,9 +242,7 @@ "username": "carmella.bennett", "email": "carmella.bennett@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-24.jsonld", @@ -302,9 +252,7 @@ "username": "levine.morrison", "email": "levine.morrison@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-25.jsonld", @@ -314,9 +262,7 @@ "username": "janice.lane", "email": "janice.lane@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-26.jsonld", @@ -326,9 +272,7 @@ "username": "woods.clay", "email": "woods.clay@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-27.jsonld", @@ -338,9 +282,7 @@ "username": "anna.abbott", "email": "anna.abbott@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-28.jsonld", @@ -350,9 +292,7 @@ "username": "atkins.levine", "email": "atkins.levine@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-29.jsonld", @@ -362,9 +302,7 @@ "username": "tiffany.dunn", "email": "tiffany.dunn@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-30.jsonld", @@ -374,9 +312,7 @@ "username": "valarie.lindsay", "email": "valarie.lindsay@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-31.jsonld", @@ -386,9 +322,7 @@ "username": "finley.solis", "email": "finley.solis@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-32.jsonld", @@ -398,9 +332,7 @@ "username": "mclaughlin.wagner", "email": "mclaughlin.wagner@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-33.jsonld", @@ -410,9 +342,7 @@ "username": "roslyn.hyde", "email": "roslyn.hyde@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-34.jsonld", @@ -422,9 +352,7 @@ "username": "rosetta.craig", "email": "rosetta.craig@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-35.jsonld", @@ -434,9 +362,7 @@ "username": "geraldine.waters", "email": "geraldine.waters@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-36.jsonld", @@ -446,9 +372,7 @@ "username": "zamora.ellison", "email": "zamora.ellison@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-37.jsonld", @@ -458,9 +382,7 @@ "username": "eileen.cantu", "email": "eileen.cantu@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-38.jsonld", @@ -470,9 +392,7 @@ "username": "lynette.oconnor", "email": "lynette.oconnor@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-39.jsonld", @@ -482,9 +402,7 @@ "username": "maritza.middleton", "email": "maritza.middleton@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-40.jsonld", @@ -494,9 +412,7 @@ "username": "norman.peters", "email": "norman.peters@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-41.jsonld", @@ -506,9 +422,7 @@ "username": "lane.navarro", "email": "lane.navarro@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-42.jsonld", @@ -518,9 +432,7 @@ "username": "oliver.fulton", "email": "oliver.fulton@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-43.jsonld", @@ -530,9 +442,7 @@ "username": "dale.bishop", "email": "dale.bishop@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-44.jsonld", @@ -542,9 +452,7 @@ "username": "wise.vazquez", "email": "wise.vazquez@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-45.jsonld", @@ -554,9 +462,7 @@ "username": "gilliam.moran", "email": "gilliam.moran@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-46.jsonld", @@ -566,9 +472,7 @@ "username": "ellison.wilson", "email": "ellison.wilson@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-47.jsonld", @@ -578,9 +482,7 @@ "username": "fanny.sandoval", "email": "fanny.sandoval@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-48.jsonld", @@ -590,9 +492,7 @@ "username": "hale.macdonald", "email": "hale.macdonald@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-49.jsonld", @@ -602,9 +502,7 @@ "username": "riley.mcfarland", "email": "riley.mcfarland@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-50.jsonld", @@ -614,9 +512,7 @@ "username": "prince.wilkerson", "email": "prince.wilkerson@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-51.jsonld", @@ -626,9 +522,7 @@ "username": "barnett.klein", "email": "barnett.klein@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-52.jsonld", @@ -638,9 +532,7 @@ "username": "amy.collins", "email": "amy.collins@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-53.jsonld", @@ -650,9 +542,7 @@ "username": "wells.grant", "email": "wells.grant@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-54.jsonld", @@ -662,9 +552,7 @@ "username": "melton.peterson", "email": "melton.peterson@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-55.jsonld", @@ -674,9 +562,7 @@ "username": "davenport.townsend", "email": "davenport.townsend@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-56.jsonld", @@ -686,9 +572,7 @@ "username": "mayo.flynn", "email": "mayo.flynn@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-57.jsonld", @@ -698,9 +582,7 @@ "username": "latoya.haynes", "email": "latoya.haynes@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-58.jsonld", @@ -710,9 +592,7 @@ "username": "catherine.parrish", "email": "catherine.parrish@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-59.jsonld", @@ -722,9 +602,7 @@ "username": "bernadette.roman", "email": "bernadette.roman@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-60.jsonld", @@ -734,9 +612,7 @@ "username": "jeanne.rosa", "email": "jeanne.rosa@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-61.jsonld", @@ -746,9 +622,7 @@ "username": "ward.cunningham", "email": "ward.cunningham@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-62.jsonld", @@ -758,9 +632,7 @@ "username": "melba.nelson", "email": "melba.nelson@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-63.jsonld", @@ -770,9 +642,7 @@ "username": "johnston.ashley", "email": "johnston.ashley@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-64.jsonld", @@ -782,9 +652,7 @@ "username": "mavis.sellers", "email": "mavis.sellers@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-65.jsonld", @@ -794,9 +662,7 @@ "username": "veronica.rollins", "email": "veronica.rollins@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-66.jsonld", @@ -806,9 +672,7 @@ "username": "renee.melendez", "email": "renee.melendez@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-67.jsonld", @@ -818,9 +682,7 @@ "username": "mccarty.gates", "email": "mccarty.gates@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-68.jsonld", @@ -830,9 +692,7 @@ "username": "day.rios", "email": "day.rios@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-69.jsonld", @@ -842,9 +702,7 @@ "username": "frye.johns", "email": "frye.johns@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-70.jsonld", @@ -854,9 +712,7 @@ "username": "cheryl.wilkinson", "email": "cheryl.wilkinson@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-71.jsonld", @@ -866,9 +722,7 @@ "username": "munoz.douglas", "email": "munoz.douglas@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-72.jsonld", @@ -878,9 +732,7 @@ "username": "debra.cook", "email": "debra.cook@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-73.jsonld", @@ -890,9 +742,7 @@ "username": "schneider.villarreal", "email": "schneider.villarreal@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-74.jsonld", @@ -902,9 +752,7 @@ "username": "hayes.holloway", "email": "hayes.holloway@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-75.jsonld", @@ -914,9 +762,7 @@ "username": "buck.velazquez", "email": "buck.velazquez@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-76.jsonld", @@ -926,9 +772,7 @@ "username": "aida.pugh", "email": "aida.pugh@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-77.jsonld", @@ -938,9 +782,7 @@ "username": "pamela.olsen", "email": "pamela.olsen@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-78.jsonld", @@ -950,9 +792,7 @@ "username": "trudy.lucas", "email": "trudy.lucas@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-79.jsonld", @@ -962,9 +802,7 @@ "username": "madge.casey", "email": "madge.casey@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-80.jsonld", @@ -974,9 +812,7 @@ "username": "nicole.palmer", "email": "nicole.palmer@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-81.jsonld", @@ -986,9 +822,7 @@ "username": "hopper.harrell", "email": "hopper.harrell@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-82.jsonld", @@ -998,9 +832,7 @@ "username": "chelsea.kennedy", "email": "chelsea.kennedy@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-83.jsonld", @@ -1010,9 +842,7 @@ "username": "townsend.morin", "email": "townsend.morin@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-84.jsonld", @@ -1022,9 +852,7 @@ "username": "valenzuela.herring", "email": "valenzuela.herring@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-85.jsonld", @@ -1034,9 +862,7 @@ "username": "iris.durham", "email": "iris.durham@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/--user-86.jsonld", @@ -1046,9 +872,7 @@ "username": "guerrero.wooten", "email": "guerrero.wooten@example.com", "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] } ] } diff --git a/examples/data/list/users.jsonld b/examples/data/list/users.jsonld index a8665402..b9c1b0b7 100644 --- a/examples/data/list/users.jsonld +++ b/examples/data/list/users.jsonld @@ -22,17 +22,13 @@ "@id": "/examples/data/list/skill-3.jsonld" } ], - "permissions": [ - "view" - ] + "permissions": ["view"] }, "profile": { "@id": "/examples/data/list/profile-1.jsonld" }, "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/user-2.jsonld", @@ -51,17 +47,13 @@ "@id": "/examples/data/list/skill-1.jsonld" } ], - "permissions": [ - "view" - ] + "permissions": ["view"] }, "profile": { "@id": "/examples/data/list/profile-2.jsonld" }, "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/user-4.jsonld", @@ -86,17 +78,13 @@ "@id": "/examples/data/list/skill-4.jsonld" } ], - "permissions": [ - "view" - ] + "permissions": ["view"] }, "profile": { "@id": "/examples/data/list/profile-4.jsonld" }, "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/list/user-3.jsonld", @@ -110,24 +98,16 @@ "skills": { "@id": "/examples/data/list/user-3-skills.jsonld", "@type": "ldp:Container", - "ldp:contains": [ - - ], - "permissions": [ - "view" - ] + "ldp:contains": [], + "permissions": ["view"] }, "profile": { "@id": "/examples/data/list/profile-3.jsonld" }, "@type": "foaf:user", - "permissions": [ - "view" - ] + "permissions": ["view"] } ], - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/list/users/balessan.jsonld b/examples/data/list/users/balessan.jsonld index 51768440..314b6245 100644 --- a/examples/data/list/users/balessan.jsonld +++ b/examples/data/list/users/balessan.jsonld @@ -261,11 +261,5 @@ "get_full_name": "rdfs:label" } ], - "permissions": [ - "change", - "control", - "view", - "delete", - "add" - ] + "permissions": ["change", "control", "view", "delete", "add"] } diff --git a/examples/data/list/users/blaisepascal.jsonld b/examples/data/list/users/blaisepascal.jsonld index 32ab48bd..752a80ad 100644 --- a/examples/data/list/users/blaisepascal.jsonld +++ b/examples/data/list/users/blaisepascal.jsonld @@ -170,11 +170,5 @@ "get_full_name": "rdfs:label" } ], - "permissions": [ - "change", - "control", - "view", - "delete", - "add" - ] + "permissions": ["change", "control", "view", "delete", "add"] } diff --git a/examples/data/map/source.jsonld b/examples/data/map/source.jsonld index 97a5affe..58a97e36 100644 --- a/examples/data/map/source.jsonld +++ b/examples/data/map/source.jsonld @@ -6,17 +6,13 @@ "federation": "events", "@id": "/examples/data/map/events.jsonld", "@type": "sib:federatedContainer", - "permissions": [ - "view" - ] + "permissions": ["view"] }, { "@id": "/examples/data/map/other-events.jsonld", "@type": "sib:federatedContainer" } ], - "permissions": [ - "view" - ], + "permissions": ["view"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" } diff --git a/examples/data/nested-forms/batch-1.jsonld b/examples/data/nested-forms/batch-1.jsonld index ed143312..724febec 100644 --- a/examples/data/nested-forms/batch-1.jsonld +++ b/examples/data/nested-forms/batch-1.jsonld @@ -1,12 +1,12 @@ { - "@id": "/examples/data/nested-forms/batch-1.jsonld", - "invoice": { - "@id": "/examples/data/nested-forms/customer-invoice-1.jsonld" - }, - "title": "Développement", - "creationDate": "2020-10-02", - "modificationDate": "2020-10-04", - "htAmount": 1500, - "permissions": [], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file + "@id": "/examples/data/nested-forms/batch-1.jsonld", + "invoice": { + "@id": "/examples/data/nested-forms/customer-invoice-1.jsonld" + }, + "title": "Développement", + "creationDate": "2020-10-02", + "modificationDate": "2020-10-04", + "htAmount": 1500, + "permissions": [], + "@context": "https://cdn.startinblox.com/owl/context.jsonld" +} diff --git a/examples/data/nested-forms/batch-2.jsonld b/examples/data/nested-forms/batch-2.jsonld index 6fed5861..ea304384 100644 --- a/examples/data/nested-forms/batch-2.jsonld +++ b/examples/data/nested-forms/batch-2.jsonld @@ -1,12 +1,12 @@ { - "@id": "/examples/data/nested-forms/batch-2.jsonld", - "invoice": { - "@id": "/examples/data/nested-forms/customer-invoice-1.jsonld" - }, - "title": "Déploiement", - "creationDate": "2020-10-02", - "modificationDate": "2020-10-04", - "htAmount": 500, - "permissions": [], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file + "@id": "/examples/data/nested-forms/batch-2.jsonld", + "invoice": { + "@id": "/examples/data/nested-forms/customer-invoice-1.jsonld" + }, + "title": "Déploiement", + "creationDate": "2020-10-02", + "modificationDate": "2020-10-04", + "htAmount": 500, + "permissions": [], + "@context": "https://cdn.startinblox.com/owl/context.jsonld" +} diff --git a/examples/data/nested-forms/customer-invoice-1-batches.jsonld b/examples/data/nested-forms/customer-invoice-1-batches.jsonld index 3e4fb5ed..6098b6ca 100644 --- a/examples/data/nested-forms/customer-invoice-1-batches.jsonld +++ b/examples/data/nested-forms/customer-invoice-1-batches.jsonld @@ -1,30 +1,30 @@ { - "@id": "/examples/data/nested-forms/customer-invoice-1-batches.jsonld", - "@type": "ldp:Container", - "ldp:contains": [ - { - "@id": "/examples/data/nested-forms/batch-1.jsonld", - "invoice": { - "@id": "/examples/data/nested-forms/customer-invoice-1.jsonld" - }, - "title": "Développement", - "creationDate": "2020-10-02", - "modificationDate": "2020-10-04", - "htAmount": 1500, - "permissions": [] - }, - { - "@id": "/examples/data/nested-forms/batch-2.jsonld", - "invoice": { - "@id": "/examples/data/nested-forms/customer-invoice-1.jsonld" - }, - "title": "Déploiement", - "creationDate": "2020-10-02", - "modificationDate": "2020-10-04", - "htAmount": 500, - "permissions": [] - } - ], - "permissions": [], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file + "@id": "/examples/data/nested-forms/customer-invoice-1-batches.jsonld", + "@type": "ldp:Container", + "ldp:contains": [ + { + "@id": "/examples/data/nested-forms/batch-1.jsonld", + "invoice": { + "@id": "/examples/data/nested-forms/customer-invoice-1.jsonld" + }, + "title": "Développement", + "creationDate": "2020-10-02", + "modificationDate": "2020-10-04", + "htAmount": 1500, + "permissions": [] + }, + { + "@id": "/examples/data/nested-forms/batch-2.jsonld", + "invoice": { + "@id": "/examples/data/nested-forms/customer-invoice-1.jsonld" + }, + "title": "Déploiement", + "creationDate": "2020-10-02", + "modificationDate": "2020-10-04", + "htAmount": 500, + "permissions": [] + } + ], + "permissions": [], + "@context": "https://cdn.startinblox.com/owl/context.jsonld" +} diff --git a/examples/data/nested-forms/customer-invoice-1.jsonld b/examples/data/nested-forms/customer-invoice-1.jsonld index 6d03b5b1..eac5c2fe 100644 --- a/examples/data/nested-forms/customer-invoice-1.jsonld +++ b/examples/data/nested-forms/customer-invoice-1.jsonld @@ -1,31 +1,31 @@ { - "@id": "/examples/data/nested-forms/customer-invoice-1.jsonld", - "@type": "hd:customerinvoice", - "customer": { - "@id": "/examples/data/nested-forms/customer-1.jsonld" - }, - "project": { - "@id": "/examples/data/nested-forms/project-1.jsonld" - }, - "batches": { - "@id": "/examples/data/nested-forms/customer-invoice-1-batches.jsonld", - "@type": "ldp:Container", - "ldp:contains": [ - { "@id": "/examples/data/nested-forms/batch-1.jsonld" }, - { "@id": "/examples/data/nested-forms/batch-2.jsonld" } - ] - }, - "identifier": "F-202001", - "title": "Création plateforme Coopedia", - "state": "pending", - "tvaRate": 20, - "creationDate": "2020-10-02", - "modificationDate": "2020-10-04", - "invoicingDate": "2020-10-10", - "additionalText": "Pénalités de retard: 4%", - "htAmount": 2000, - "tvaAmount": 400, - "ttcAmount": 2400, - "permissions": [], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file + "@id": "/examples/data/nested-forms/customer-invoice-1.jsonld", + "@type": "hd:customerinvoice", + "customer": { + "@id": "/examples/data/nested-forms/customer-1.jsonld" + }, + "project": { + "@id": "/examples/data/nested-forms/project-1.jsonld" + }, + "batches": { + "@id": "/examples/data/nested-forms/customer-invoice-1-batches.jsonld", + "@type": "ldp:Container", + "ldp:contains": [ + { "@id": "/examples/data/nested-forms/batch-1.jsonld" }, + { "@id": "/examples/data/nested-forms/batch-2.jsonld" } + ] + }, + "identifier": "F-202001", + "title": "Création plateforme Coopedia", + "state": "pending", + "tvaRate": 20, + "creationDate": "2020-10-02", + "modificationDate": "2020-10-04", + "invoicingDate": "2020-10-10", + "additionalText": "Pénalités de retard: 4%", + "htAmount": 2000, + "tvaAmount": 400, + "ttcAmount": 2400, + "permissions": [], + "@context": "https://cdn.startinblox.com/owl/context.jsonld" +} diff --git a/examples/data/project.jsonld b/examples/data/project.jsonld index 18beaf04..dbe84128 100644 --- a/examples/data/project.jsonld +++ b/examples/data/project.jsonld @@ -10,11 +10,6 @@ "jabberRoom": true, "texte": "ceci est un texte avec du **markdown** \u00e0 l'int\u00e9rieur and a [link](https://startinblox.com).", "@type": "doap:project", - "permissions": [ - "control", - "add", - "delete", - "change" - ], + "permissions": ["control", "add", "delete", "change"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/project2.jsonld b/examples/data/project2.jsonld index 7a326b5d..b7064441 100644 --- a/examples/data/project2.jsonld +++ b/examples/data/project2.jsonld @@ -9,12 +9,6 @@ "jabberID": "fusee@conference.happy-dev.fr", "jabberRoom": true, "@type": "doap:project", - "permissions": [ - "view", - "control", - "add", - "delete", - "change" - ], + "permissions": ["view", "control", "add", "delete", "change"], "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} \ No newline at end of file +} diff --git a/examples/data/xwiki.jsonld b/examples/data/xwiki.jsonld index 6fa92f63..7a874e44 100644 --- a/examples/data/xwiki.jsonld +++ b/examples/data/xwiki.jsonld @@ -116,11 +116,5 @@ "fieldName": "wysiwyg" } }, - "permissions": [ - "view", - "control", - "add", - "delete", - "change" - ] -} \ No newline at end of file + "permissions": ["view", "control", "add", "delete", "change"] +} diff --git a/examples/e2e/helpers.css b/examples/e2e/helpers.css index 2c7f3bdd..600a424a 100644 --- a/examples/e2e/helpers.css +++ b/examples/e2e/helpers.css @@ -1,7 +1,7 @@ -html{ +html { background-color: green; } -html::before{ - content: 'styles loaded'; -} \ No newline at end of file +html::before { + content: "styles loaded"; +} diff --git a/examples/e2e/helpers.js b/examples/e2e/helpers.js index 42c4dd90..7a663e54 100644 --- a/examples/e2e/helpers.js +++ b/examples/e2e/helpers.js @@ -1 +1 @@ -window.scriptLoaded = true; \ No newline at end of file +window.scriptLoaded = true; diff --git a/examples/styles.css b/examples/styles.css index 812f75b7..4b0a6e76 100644 --- a/examples/styles.css +++ b/examples/styles.css @@ -44,7 +44,7 @@ solid-route[active] { background-color: #ccc; } -[active]{ +[active] { outline: 2px dotted; } diff --git a/package.json b/package.json index 43d31452..fd8a0478 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,7 @@ "directories": { "example": "examples" }, - "files": [ - "dist", - "doc" - ], + "files": ["dist", "doc"], "scripts": { "build": "vite build", "watch": "vite build --watch --sourcemap 'inline'", diff --git a/server.js b/server.js index 3f08c387..174608b9 100644 --- a/server.js +++ b/server.js @@ -37,11 +37,11 @@ app.use(cors()); const jsonData = await fs.readFile( './examples/data/list/users-mocked.jsonld', - { encoding: 'utf8' } + { encoding: 'utf8' }, ); const data = JSON.parse(jsonData); - const list = data['ldp:contains'].filter((user) => - user['first_name'].toLowerCase().includes(val.toLowerCase()) + const list = data['ldp:contains'].filter(user => + user['first_name'].toLowerCase().includes(val.toLowerCase()), ); data['ldp:contains'] = limit ? list.slice(offset, offset + limit) : list; diff --git a/src/components/solid-ac-checker.ts b/src/components/solid-ac-checker.ts index fdadfe8d..3fec2c6f 100644 --- a/src/components/solid-ac-checker.ts +++ b/src/components/solid-ac-checker.ts @@ -14,34 +14,40 @@ export const SolidAcChecker = { noPermission: { type: String, default: '', - } - }, - populate: trackRenderAsync( - async function(): Promise<void> { - if (!this.resource) return; - let displayElement: boolean; - const ContextParser = JSONLDContextParser.ContextParser; - const permissions = await this.resource.permissions; - if (this.permission) { // User has permission of ... - displayElement = permissions.some((p:any) => { - return ContextParser.expandTerm(p, this.context, true) === this.permission; - }); - } else if (this.noPermission) { // User has no permission of ... - displayElement = permissions.every((p:any) => { - return ContextParser.expandTerm(p, this.context, true) !== this.noPermission; - }); - } else { // No parameter provided - console.warn('solid-ac-checker: you should define at least one of "permission" or "no-permission" attribute.'); - return; - } - - if (displayElement) this.element.removeAttribute('hidden'); }, - "SolidAcChecker:populate" - ), + }, + populate: trackRenderAsync(async function (): Promise<void> { + if (!this.resource) return; + let displayElement: boolean; + const ContextParser = JSONLDContextParser.ContextParser; + const permissions = await this.resource.permissions; + if (this.permission) { + // User has permission of ... + displayElement = permissions.some((p: any) => { + return ( + ContextParser.expandTerm(p, this.context, true) === this.permission + ); + }); + } else if (this.noPermission) { + // User has no permission of ... + displayElement = permissions.every((p: any) => { + return ( + ContextParser.expandTerm(p, this.context, true) !== this.noPermission + ); + }); + } else { + // No parameter provided + console.warn( + 'solid-ac-checker: you should define at least one of "permission" or "no-permission" attribute.', + ); + return; + } + + if (displayElement) this.element.removeAttribute('hidden'); + }, 'SolidAcChecker:populate'), empty(): void { this.element.setAttribute('hidden', ''); - } + }, }; -Sib.register(SolidAcChecker); \ No newline at end of file +Sib.register(SolidAcChecker); diff --git a/src/components/solid-calendar.ts b/src/components/solid-calendar.ts index 90fac451..c7649962 100644 --- a/src/components/solid-calendar.ts +++ b/src/components/solid-calendar.ts @@ -10,26 +10,27 @@ import { html, render } from 'lit'; export const SolidCalendar = { name: 'solid-calendar', - use: [ - ListMixin, - StoreMixin, - NextMixin - ], + use: [ListMixin, StoreMixin, NextMixin], initialState: { - subscriptions: null + subscriptions: null, }, created(): void { - importInlineCSS('tui-calendar', () => import('tui-calendar/dist/tui-calendar.css?inline')) + importInlineCSS( + 'tui-calendar', + () => import('tui-calendar/dist/tui-calendar.css?inline'), + ); const id = uniqID(); const template = html`<div id=${id} style="width:100%;height:100%;"></div>`; render(template, this.element); - this.calendar = new Calendar(this.element.querySelector(`#${id}`), { defaultView: 'month' }); + this.calendar = new Calendar(this.element.querySelector(`#${id}`), { + defaultView: 'month', + }); this.calendar.on('clickSchedule', this.dispatchSelect.bind(this)); this.subscriptions = new Map(); }, get extra_context(): object { - return { date: "http://www.w3.org/2001/XMLSchema#dateTime" } + return { date: 'http://www.w3.org/2001/XMLSchema#dateTime' }; }, dispatchSelect(event: Event): void { const resource = { '@id': event['schedule'].id }; @@ -40,9 +41,12 @@ export const SolidCalendar = { }, async appendChildElt(resourceId: string) { const resource = await store.getData(resourceId, this.context); - if(!resource) return; + if (!resource) return; if (!this.subscriptions.get(resourceId)) { - this.subscriptions.set(resourceId, PubSub.subscribe(resourceId, () => this.updateDOM())) + this.subscriptions.set( + resourceId, + PubSub.subscribe(resourceId, () => this.updateDOM()), + ); } // TODO : mixin gestion des enfants const date = await resource['date']; const name = await resource['name']; @@ -60,7 +64,7 @@ export const SolidCalendar = { }, empty(): void { this.calendar.clear(); - } + }, }; -Sib.register(SolidCalendar); \ No newline at end of file +Sib.register(SolidCalendar); diff --git a/src/components/solid-delete.ts b/src/components/solid-delete.ts index d0fe9f04..483175f0 100644 --- a/src/components/solid-delete.ts +++ b/src/components/solid-delete.ts @@ -16,7 +16,7 @@ export const SolidDelete = { type: String, default: null, callback: function () { - this.resourceId = this.dataSrc; + this.resourceId = this.dataSrc; }, }, dataLabel: { @@ -25,7 +25,7 @@ export const SolidDelete = { callback: function (newValue: string, oldValue: string) { if (newValue !== oldValue) this.planRender(); }, - } + }, }, initialState: { renderPlanned: false, @@ -51,25 +51,26 @@ export const SolidDelete = { return store.delete(this.dataSrc, this.context).then(response => { if (!response.ok) return; this.goToNext(null); - const eventData = { detail: { resource: { "@id": this.dataSrc } }, bubbles: true }; + const eventData = { + detail: { resource: { '@id': this.dataSrc } }, + bubbles: true, + }; this.element.dispatchEvent(new CustomEvent('save', eventData)); this.element.dispatchEvent(new CustomEvent('resourceDeleted', eventData)); // Deprecated. To remove in 0.15 - }) + }); }, - validateModal() { // Send method to validationMixin, used by the dialog modal and performAction method + validateModal() { + // Send method to validationMixin, used by the dialog modal and performAction method return this.deletion(); }, update() { this.render(); }, - render: trackRenderAsync( - async function(): Promise<void> { - await this.replaceAttributesData(false); - const button = html`<button @click=${this.delete.bind(this)}>${this.dataLabel || this.t("solid-delete.button")}</button>${this.getModalDialog()}`; - render(button, this.element); - }, - "SolidDelete:render" - ) + render: trackRenderAsync(async function (): Promise<void> { + await this.replaceAttributesData(false); + const button = html`<button @click=${this.delete.bind(this)}>${this.dataLabel || this.t('solid-delete.button')}</button>${this.getModalDialog()}`; + render(button, this.element); + }, 'SolidDelete:render'), }; -Sib.register(SolidDelete); \ No newline at end of file +Sib.register(SolidDelete); diff --git a/src/components/solid-display.ts b/src/components/solid-display.ts index 34c00411..b2814584 100644 --- a/src/components/solid-display.ts +++ b/src/components/solid-display.ts @@ -54,7 +54,8 @@ export const SolidDisplay = { }, detached(): void { if (this.activeSubscription) PubSub.unsubscribe(this.activeSubscription); - if (this.removeActiveSubscription) PubSub.unsubscribe(this.removeActiveSubscription); + if (this.removeActiveSubscription) + PubSub.unsubscribe(this.removeActiveSubscription); }, // Update subscription when id changes updateNavigateSubscription() { @@ -63,7 +64,7 @@ export const SolidDisplay = { if (this.resourceId) { this.activeSubscription = PubSub.subscribe( 'enterRoute.' + this.resourceId, - this.addActiveCallback.bind(this) + this.addActiveCallback.bind(this), ); } }, @@ -71,7 +72,7 @@ export const SolidDisplay = { this.element.setAttribute('active', ''); this.removeActiveSubscription = PubSub.subscribe( 'leaveRoute', - this.removeActiveCallback.bind(this) + this.removeActiveCallback.bind(this), ); }, removeActiveCallback() { @@ -91,16 +92,16 @@ export const SolidDisplay = { dispatchSelect(event: Event, resourceId: string): void { const linkTarget = (event!.target as Element).closest('a'); if (linkTarget && linkTarget.hasAttribute('href')) return; - const resource = { "@id": resourceId }; + const resource = { '@id': resourceId }; this.element.dispatchEvent( new CustomEvent('resourceSelect', { detail: { resource: resource } }), ); this.goToNext(resource); }, - - enterKeydownAction (event, resourceId: string): void { + + enterKeydownAction(event, resourceId: string): void { if (event.keyCode === 13) { - const resource = { "@id" : resourceId }; + const resource = { '@id': resourceId }; this.goToNext(resource); } }, @@ -118,7 +119,7 @@ export const SolidDisplay = { fields=${ifDefined(this.fields)} ...=${spread(attributes)} ></solid-display> - ` + `; return template; }, @@ -128,8 +129,9 @@ export const SolidDisplay = { */ async appendSingleElt(parent: HTMLElement): Promise<void> { const fields = await this.getFields(); - const widgetTemplates = await Promise.all( // generate all widget templates - fields.map((field: string) => this.createWidgetTemplate(field)) + const widgetTemplates = await Promise.all( + // generate all widget templates + fields.map((field: string) => this.createWidgetTemplate(field)), ); render(html`${widgetTemplates}`, parent); }, @@ -143,47 +145,43 @@ export const SolidDisplay = { * @param div * @param context */ - renderDOM: trackRenderAsync(async function( resources: object[], + renderDOM: trackRenderAsync(async function ( + resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string, ) { const attributes = this.getChildAttributes(); // get attributes of children only once // and create a child template for each resource - const template = html`${resources.map(r => r ? this.getChildTemplate(r['@id'], attributes) : null)}`; + const template = html`${resources.map(r => (r ? this.getChildTemplate(r['@id'], attributes) : null))}`; render(template, div); - + const nextProcessor = listPostProcessors.shift(); if (nextProcessor) - await nextProcessor( - resources, - listPostProcessors, - div, - context - ); - }, "SolidDisplay:renderDom"), + await nextProcessor(resources, listPostProcessors, div, context); + }, 'SolidDisplay:renderDom'), /** * Get attributes to dispatch to children from current element */ getChildAttributes() { - const attributes:{[key:string]: string} = {}; + const attributes: { [key: string]: string } = {}; for (let attr of this.element.attributes) { //copy widget and value attributes if ( - attr.name.startsWith('value-') || - attr.name.startsWith('label-') || - attr.name.startsWith('placeholder-') || - attr.name.startsWith('widget-') || - attr.name.startsWith('class-') || - attr.name.startsWith('multiple-') || - attr.name.startsWith('editable-') || - attr.name.startsWith('action-') || - attr.name.startsWith('default-') || - attr.name.startsWith('link-text-') || - attr.name.startsWith('target-src-') || - attr.name.startsWith('data-label-') || + attr.name.startsWith('value-') || + attr.name.startsWith('label-') || + attr.name.startsWith('placeholder-') || + attr.name.startsWith('widget-') || + attr.name.startsWith('class-') || + attr.name.startsWith('multiple-') || + attr.name.startsWith('editable-') || + attr.name.startsWith('action-') || + attr.name.startsWith('default-') || + attr.name.startsWith('link-text-') || + attr.name.startsWith('target-src-') || + attr.name.startsWith('data-label-') || attr.name == 'extra-context' ) attributes[attr.name] = attr.value; @@ -195,7 +193,7 @@ export const SolidDisplay = { } } return attributes; - } + }, }; Sib.register(SolidDisplay); diff --git a/src/components/solid-form-search.ts b/src/components/solid-form-search.ts index f49336dc..74b35f69 100644 --- a/src/components/solid-form-search.ts +++ b/src/components/solid-form-search.ts @@ -14,7 +14,7 @@ import { trackRenderAsync } from '../logger'; export const SolidFormSearch = { name: 'solid-form-search', use: [WidgetMixin, AttributeBinderMixin, ContextMixin], - debounceTimeout: undefined as (number | undefined), + debounceTimeout: undefined as number | undefined, attributes: { defaultWidget: { type: String, @@ -29,7 +29,7 @@ export const SolidFormSearch = { }, submitWidget: { type: String, - default: undefined + default: undefined, }, classSubmitButton: { type: String, @@ -39,13 +39,13 @@ export const SolidFormSearch = { type: String, default: null, callback: function (value: boolean) { - if (value === null) this.populate() - } + if (value === null) this.populate(); + }, }, debounce: { type: Number, - default: 0 // Avoiding blink effect with static values - } + default: 0, // Avoiding blink effect with static values + }, }, initialState: { error: '', @@ -65,7 +65,7 @@ export const SolidFormSearch = { get value(): SearchQuery { const values: SearchQuery = {}; - this.widgets.forEach((widget) => { + this.widgets.forEach(widget => { if (widget == null) return; const name = (widget.component || widget).name; if (name == null) return; @@ -77,7 +77,7 @@ export const SolidFormSearch = { type: widget.component.type, list: !!widget.component.multiple, value: value, - } + }; values[name] = value; }); return values; @@ -85,54 +85,69 @@ export const SolidFormSearch = { getWidget(field: string, isSet: boolean = false): WidgetInterface { let tagName = ''; // If auto-range-[field] exists, create range-[field] and sets its value - if(this.element.hasAttribute('auto-range-' + field) && !this.element.hasAttribute('range-' + field)) { + if ( + this.element.hasAttribute('auto-range-' + field) && + !this.element.hasAttribute('range-' + field) + ) { const idField = `${this.rangeId}_${field}`; this.element.setAttribute('range-' + field, 'store://local.' + idField); this.populate(); } - + const widgetAttribute = this.element.getAttribute('widget-' + field); // Choose widget - if (!widgetAttribute && (this.element.hasAttribute('range-' + field) || this.element.hasAttribute('enum-' + field))) { - tagName = 'solid-form-dropdown' + if ( + !widgetAttribute && + (this.element.hasAttribute('range-' + field) || + this.element.hasAttribute('enum-' + field)) + ) { + tagName = 'solid-form-dropdown'; } else { - tagName = widgetAttribute || (!isSet ? this.defaultWidget : this.defaultSetWidget); + tagName = + widgetAttribute || + (!isSet ? this.defaultWidget : this.defaultSetWidget); } // Create widget - if (!customElements.get(tagName)) { // component does not exist + if (!customElements.get(tagName)) { + // component does not exist if (tagName.startsWith('solid')) newWidgetFactory(tagName); // solid- -> create it } return this.widgetFromTagName(tagName); }, async attach(elm: any) { - if(this.attachedElements.has(elm)) return; + if (this.attachedElements.has(elm)) return; this.attachedElements.add(elm); await this.updateAutoRanges(); }, async detach(elm: any) { - if(!this.attachedElements.has(elm)) return; + if (!this.attachedElements.has(elm)) return; this.attachedElements.delete(elm); await this.updateAutoRanges(); }, async updateAutoRanges() { - for(const attr of (this.element as Element).attributes) { + for (const attr of (this.element as Element).attributes) { if (!attr['name'].startsWith('auto-range-')) continue; - let fieldName = attr.value !== '' ? attr.value : attr['name'].replace('auto-range-', ''); + let fieldName = + attr.value !== '' + ? attr.value + : attr['name'].replace('auto-range-', ''); const autoRangeValues = new Set(); - for(const elm of this.attachedElements) { - for(const value of await elm.getValuesOfField(fieldName)) { + for (const elm of this.attachedElements) { + for (const value of await elm.getValuesOfField(fieldName)) { autoRangeValues.add(value); } } const idField = `${this.rangeId}_${fieldName}`; const id = `store://local.${idField}`; - const ldpContains = Array.from(autoRangeValues).map(id => ({'@id' : id})); + const ldpContains = Array.from(autoRangeValues).map(id => ({ + '@id': id, + })); const data = { - "@type": "ldp:Container", - "@context": this.context, - "ldp:contains" : ldpContains, + '@type': 'ldp:Container', + '@context': this.context, + 'ldp:contains': ldpContains, }; sibStore.setLocalData(data, id); } @@ -153,42 +168,44 @@ export const SolidFormSearch = { detail: { value: eventOptions.value, inputLabel: eventOptions.inputLabel, - type: eventOptions.type - } + type: eventOptions.type, + }, }), ); }, async inputChange(input: EventTarget): Promise<void> { // FIXME: Improve this as we need to support more than input and single select. // What about multiple select, checkboxes, radio buttons, etc? - let parentElementLabel = (input as HTMLInputElement)?.parentElement?.getAttribute('label'); + let parentElementLabel = ( + input as HTMLInputElement + )?.parentElement?.getAttribute('label'); try { - const selectedLabel = (input as HTMLSelectElement).selectedOptions[0].textContent?.trim(); - this.change( - this.value, - { - value: selectedLabel, - inputLabel: parentElementLabel, - type: 'select' - } - ); + const selectedLabel = ( + input as HTMLSelectElement + ).selectedOptions[0].textContent?.trim(); + this.change(this.value, { + value: selectedLabel, + inputLabel: parentElementLabel, + type: 'select', + }); } catch { - this.change(this.value, - { - value: (input as HTMLInputElement).value, - inputLabel: parentElementLabel, - type: 'input' - } - ); + this.change(this.value, { + value: (input as HTMLInputElement).value, + inputLabel: parentElementLabel, + type: 'input', + }); } }, getSubmitTemplate() { return html` <div class=${ifDefined(this.classSubmitButton)}> - ${this.submitWidget === 'button' ? html`<button type="submit">${this.submitButton || ''}</button>` : - html`<input type="submit" value=${ifDefined(this.submitButton || undefined)}>`} + ${ + this.submitWidget === 'button' + ? html`<button type="submit">${this.submitButton || ''}</button>` + : html`<input type="submit" value=${ifDefined(this.submitButton || undefined)}>` + } </div> - ` + `; }, empty(): void {}, debounceInput(input: EventTarget | null) { @@ -198,30 +215,30 @@ export const SolidFormSearch = { this.inputChange(input); }, this.debounce); }, - populate: trackRenderAsync( - async function(): Promise<void> { - await this.replaceAttributesData(); - if(this.submitButton == null) { - this.element.addEventListener('input', (e: Event) => this.debounceInput(e.target)); - } else { - this.element.addEventListener('submit', (e: Event) => { - e.preventDefault(); - this.inputChange(e.target); - }); - } - const fields = await this.getFields(); - const widgetTemplates = await Promise.all(fields.map((field: string) => this.createWidgetTemplate(field))); - const template = html` + populate: trackRenderAsync(async function (): Promise<void> { + await this.replaceAttributesData(); + if (this.submitButton == null) { + this.element.addEventListener('input', (e: Event) => + this.debounceInput(e.target), + ); + } else { + this.element.addEventListener('submit', (e: Event) => { + e.preventDefault(); + this.inputChange(e.target); + }); + } + const fields = await this.getFields(); + const widgetTemplates = await Promise.all( + fields.map((field: string) => this.createWidgetTemplate(field)), + ); + const template = html` <form> ${widgetTemplates} ${this.submitButton == null ? '' : this.getSubmitTemplate()} </form> `; - render(template, this.element); - }, - "SolidFormSearch:populate" - ) - + render(template, this.element); + }, 'SolidFormSearch:populate'), }; -Sib.register(SolidFormSearch); \ No newline at end of file +Sib.register(SolidFormSearch); diff --git a/src/components/solid-form.ts b/src/components/solid-form.ts index 0fa821ac..e63e83c9 100644 --- a/src/components/solid-form.ts +++ b/src/components/solid-form.ts @@ -17,7 +17,7 @@ export const SolidForm = { attributes: { autosave: { type: Boolean, - default: null + default: null, }, classSubmitButton: { type: String, @@ -25,15 +25,15 @@ export const SolidForm = { }, defaultWidget: { type: String, - default: 'solid-form-label-text' + default: 'solid-form-label-text', }, naked: { type: Boolean, - default: null + default: null, }, partial: { type: Boolean, - default: null + default: null, }, submitButton: { type: String, @@ -44,11 +44,11 @@ export const SolidForm = { }, submitWidget: { type: String, - default: null + default: null, }, }, initialState: { - error: '' + error: '', }, get defaultMultipleWidget(): string { return 'solid-multiple-form'; @@ -58,7 +58,7 @@ export const SolidForm = { }, get value(): object { const values = {}; - this.widgets.forEach((widget) => { + this.widgets.forEach(widget => { const name = (widget.component || widget).name; if (name == null) return; let value = widget.component ? widget.component.getValue() : widget.value; @@ -68,7 +68,8 @@ export const SolidForm = { setDeepProperty(values, name.split('.'), value); }); // add @id if edition - if (this.resource && !this.resource.isContainer?.()) values['@id'] = this.resourceId; + if (this.resource && !this.resource.isContainer?.()) + values['@id'] = this.resourceId; return values; }, get isNaked(): boolean { @@ -88,19 +89,24 @@ export const SolidForm = { let object = await this.resource[predicate]; // edge-case where object is null because predicate needs to be expanded manually (arrays) if (!object) { - object = await this.resource[store.getExpandedPredicate(predicate, this.context)]; + object = + await this.resource[ + store.getExpandedPredicate(predicate, this.context) + ]; } // Nested containers - if (object - && object['@id'] - && !value[predicate]['@id']) value[predicate]['@id'] = object['@id']; + if (object && object['@id'] && !value[predicate]['@id']) + value[predicate]['@id'] = object['@id']; //FIXME: Edge case of array support, ugly management - if (object && !object['@id'] - && Array.isArray(object) - && value[predicate].length == 0 - && object.length > 0) { + if ( + object && + !object['@id'] && + Array.isArray(object) && + value[predicate].length == 0 && + object.length > 0 + ) { value[predicate] = object; } } @@ -113,11 +119,17 @@ export const SolidForm = { // Choose widget if (!widgetAttribute && this.element.hasAttribute('upload-url-' + field)) { - tagName = 'solid-form-file' - } else if (!widgetAttribute && (this.element.hasAttribute('range-' + field) || this.element.hasAttribute('enum-' + field))) { - tagName = 'solid-form-dropdown' + tagName = 'solid-form-file'; + } else if ( + !widgetAttribute && + (this.element.hasAttribute('range-' + field) || + this.element.hasAttribute('enum-' + field)) + ) { + tagName = 'solid-form-dropdown'; } else { - tagName = widgetAttribute || (!isSet ? this.defaultWidget : this.defaultSetWidget); + tagName = + widgetAttribute || + (!isSet ? this.defaultWidget : this.defaultSetWidget); } // Create widget return this.widgetFromTagName(tagName); @@ -138,15 +150,16 @@ export const SolidForm = { let saved; try { if (this.partial == null) { - saved = resource['@id'] ? - await store.put(resource, this.resourceId) : - await store.post(resource, this.resourceId); + saved = resource['@id'] + ? await store.put(resource, this.resourceId) + : await store.post(resource, this.resourceId); } else { saved = await store.patch(resource, this.resourceId); } } catch (e: any) { this.toggleLoaderHidden(true); - if (e) { // if server error + if (e) { + // if server error e.json().then(error => this.showError(error)); throw e; } @@ -156,7 +169,7 @@ export const SolidForm = { bubbles: true, detail: { resource: resource, - id: saved || null + id: saved || null, }, }), ); @@ -166,10 +179,12 @@ export const SolidForm = { async submitForm(): Promise<void> { let id: string; try { - id = await this.save() || this.getFormValue()['@id']; - } catch (e) { return; } + id = (await this.save()) || this.getFormValue()['@id']; + } catch (e) { + return; + } this.reset(); - this.goToNext({'@id': id}) + this.goToNext({ '@id': id }); }, async onInput(): Promise<void> { const formValue = await this.getFormValue(); @@ -183,28 +198,36 @@ export const SolidForm = { displayErrorMessage(errors: [string, any][], errorFullName: string = '') { errors.forEach((member: [string, any]) => { let errorNextName: string = Object.values(member)[0]; - let subErrorName = (errorFullName === "" ? errorNextName : errorFullName.concat('.' + errorNextName)); - let errorFieldName = "" + let subErrorName = + errorFullName === '' + ? errorNextName + : errorFullName.concat('.' + errorNextName); + let errorFieldName = ''; - if (errorFullName) errorFieldName = errorFullName.concat('.' + errorNextName); + if (errorFullName) + errorFieldName = errorFullName.concat('.' + errorNextName); else errorFieldName = errorNextName; if (errorFieldName) { - let formField = this.element.querySelector(`[name="${errorFieldName}"]`); + let formField = this.element.querySelector( + `[name="${errorFieldName}"]`, + ); if (formField) { formField.classList.add('error'); let errorParagraph = document.createElement('p'); if (Array.isArray(Object.values(member)[1]) === true) { - Object.values(member)[1].forEach((error) => { + Object.values(member)[1].forEach(error => { let errorText = document.createElement('p'); errorText.textContent = error; errorParagraph.appendChild(errorText); }); } else if (typeof Object.values(member)[1] === 'object') { // @ts-ignore - for (const [key, value] of Object.entries(Object.values(member)[1])) { + for (const [key, value] of Object.entries( + Object.values(member)[1], + )) { if (Array.isArray(value)) { - value.forEach((error) => { + value.forEach(error => { let errorText = document.createElement('p'); errorText.textContent = error; errorParagraph.appendChild(errorText); @@ -226,13 +249,15 @@ export const SolidForm = { if (!Array.isArray(Object.values(member)[1]) === true) { let objectErrors = Object.values(member)[1]; let subErrors = Object.entries(objectErrors); - this.displayErrorMessage(subErrors, subErrorName) + this.displayErrorMessage(subErrors, subErrorName); } }); }, empty(): void {}, showError(e: object) { - let errors = Object.entries(e).filter(field => !field[0].startsWith('@context')); + let errors = Object.entries(e).filter( + field => !field[0].startsWith('@context'), + ); this.displayErrorMessage(errors); const errorTemplate = html`<p>${this.t('solid-form.validation-error')}</p>`; @@ -242,10 +267,11 @@ export const SolidForm = { }, hideError() { let formErrors = this.element.querySelectorAll('.error-message'); - if (formErrors) formErrors.forEach((error) => error.remove()); + if (formErrors) formErrors.forEach(error => error.remove()); let errorFields = this.element.querySelectorAll('.error'); - if (errorFields) errorFields.forEach((errorField) => errorField.classList.remove('error')); + if (errorFields) + errorFields.forEach(errorField => errorField.classList.remove('error')); const parentElement = this.element.querySelector('[data-id=error]'); if (parentElement) render('', parentElement); @@ -259,47 +285,55 @@ export const SolidForm = { this.performAction(); // In validationMixin, method defining what to do according to the present attributes } }, - validateModal() { //send method to validationMixin, used by the dialog modal and performAction method + validateModal() { + //send method to validationMixin, used by the dialog modal and performAction method return this.submitForm(); }, onReset() { - if (!this.isNaked) setTimeout(() => this.onInput()) + if (!this.isNaked) setTimeout(() => this.onInput()); }, getSubmitTemplate() { return html` <div class=${ifDefined(this.classSubmitButton)}> - ${this.submitWidget === 'button' ? html`<button type="submit">${this.submitButton || this.t("solid-form.submit-button")}</button>` : - html`<input type="submit" value=${this.submitButton || this.t("solid-form.submit-button")}>`} + ${ + this.submitWidget === 'button' + ? html`<button type="submit">${this.submitButton || this.t('solid-form.submit-button')}</button>` + : html`<input type="submit" value=${this.submitButton || this.t('solid-form.submit-button')}>` + } </div> - ` + `; }, - populate: trackRenderAsync( - async function(): Promise<void> { - this.element.oninput = () => this.onInput(); // prevent from firing change multiple times - this.element.onchange = () => this.onChange(); - const fields = await this.getFields(); - const widgetTemplates = await Promise.all(fields.map((field: string) => this.createWidgetTemplate(field))); - const template = html` + populate: trackRenderAsync(async function (): Promise<void> { + this.element.oninput = () => this.onInput(); // prevent from firing change multiple times + this.element.onchange = () => this.onChange(); + const fields = await this.getFields(); + const widgetTemplates = await Promise.all( + fields.map((field: string) => this.createWidgetTemplate(field)), + ); + const template = html` <div data-id="error"></div> - ${!this.isNaked ? html` + ${ + !this.isNaked + ? html` <form @submit=${this.onSubmit.bind(this)} @reset=${this.onReset.bind(this)} > ${widgetTemplates} ${!this.isSavingAutomatically ? this.getSubmitTemplate() : ''} - ${this.element.hasAttribute('reset') - ? html`<input type="reset" />` : ''} + ${ + this.element.hasAttribute('reset') + ? html`<input type="reset" />` + : '' + } </form> - ` : html`${widgetTemplates}` + ` + : html`${widgetTemplates}` } ${this.getModalDialog()} `; - render(template, this.element); - }, - "SolidForm:populate" - ) - + render(template, this.element); + }, 'SolidForm:populate'), }; -Sib.register(SolidForm); \ No newline at end of file +Sib.register(SolidForm); diff --git a/src/components/solid-lang.ts b/src/components/solid-lang.ts index 1902511f..4bb48967 100644 --- a/src/components/solid-lang.ts +++ b/src/components/solid-lang.ts @@ -9,19 +9,19 @@ export const SolidLang = { attributes: { lang: { type: String, - default: null + default: null, }, dataLabel: { type: String, - default: null - } + default: null, + }, }, created(): void { this.render(); }, - languageLoader () { + languageLoader() { store.selectLanguage(this.lang); location.reload(); }, @@ -30,7 +30,7 @@ export const SolidLang = { let template = html`<button @click=${this.languageLoader.bind(this)}>${this.dataLabel}</button>`; render(template, this.element); - } + }, }; -Sib.register(SolidLang); \ No newline at end of file +Sib.register(SolidLang); diff --git a/src/components/solid-map.ts b/src/components/solid-map.ts index 27eb5692..89da0bfc 100644 --- a/src/components/solid-map.ts +++ b/src/components/solid-map.ts @@ -35,32 +35,44 @@ export const SolidMap = { attributes: { clustering: { type: Boolean, - default: null - } + default: null, + }, }, initialState: { markers: { - default: null + default: null, }, subscriptions: null, resetPlanned: false, - hasBeenResetOnce: false + hasBeenResetOnce: false, }, created(): void { - importInlineCSS('leaflet', () => import('leaflet/dist/leaflet.css?inline')) - importInlineCSS('default-theme', () => import('../style/default-theme.css?inline')) - importInlineCSS('marker-cluster', () => import('leaflet.markercluster/dist/MarkerCluster.css?inline')) - importInlineCSS('marker-cluster-default', () => import('leaflet.markercluster/dist/MarkerCluster.Default.css?inline')) + importInlineCSS('leaflet', () => import('leaflet/dist/leaflet.css?inline')); + importInlineCSS( + 'default-theme', + () => import('../style/default-theme.css?inline'), + ); + importInlineCSS( + 'marker-cluster', + () => import('leaflet.markercluster/dist/MarkerCluster.css?inline'), + ); + importInlineCSS( + 'marker-cluster-default', + () => + import('leaflet.markercluster/dist/MarkerCluster.Default.css?inline'), + ); // reset when it becomes visible to prevent bug https://git.startinblox.com/framework/sib-core/issues/661 document.body.addEventListener('navigate', () => - setTimeout(() => this.isVisible && !this.hasBeenResetOnce && this.reset()) + setTimeout( + () => this.isVisible && !this.hasBeenResetOnce && this.reset(), + ), ); this.markers = []; this.subscriptions = new Map(); }, get isVisible() { - return this.element.offsetParent !== null + return this.element.offsetParent !== null; }, attached(): void { const id = uniqID(); @@ -73,7 +85,7 @@ export const SolidMap = { this.map = L.map(div); L.tileLayer( - 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png' + 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png', ).addTo(this.map); if (this.clustering !== null) { @@ -82,7 +94,8 @@ export const SolidMap = { } }, reset() { - if (this.isVisible) { // reset only if visible + if (this.isVisible) { + // reset only if visible this.map.invalidateSize(); if (this.markers.length) { @@ -102,14 +115,14 @@ export const SolidMap = { setTimeout(() => { this.reset(); this.resetPlanned = false; - }) + }); } }, dispatchSelect(event: CustomEvent): void { const target = event.target as Element; const resource = target['options'].resource; this.element.dispatchEvent( - new CustomEvent('resourceSelect', { detail: { resource: resource } }) + new CustomEvent('resourceSelect', { detail: { resource: resource } }), ); this.goToNext(resource); }, @@ -122,31 +135,38 @@ export const SolidMap = { async appendChildElt(resourceId: string, groupClass: string) { const resource = await store.getData(resourceId, this.context); if (!this.subscriptions.get(resourceId)) { - this.subscriptions.set(resourceId, PubSub.subscribe(resourceId, () => this.updateDOM())) + this.subscriptions.set( + resourceId, + PubSub.subscribe(resourceId, () => this.updateDOM()), + ); } if (!resource) return; const lat = await resource['lat']; const lng = await resource['lng']; if (lat && lng) { - const icon = L.divIcon({ // create the icon, doc here: https://leafletjs.com/reference-1.6.0.html#icon + const icon = L.divIcon({ + // create the icon, doc here: https://leafletjs.com/reference-1.6.0.html#icon className: 'sib-custom-marker ' + groupClass, // default class used for styling iconSize: [8, 8], iconAnchor: [12, 34], - popupAnchor: [0,-34] + popupAnchor: [0, -34], }); // create a marker, doc here: https://leafletjs.com/reference-1.6.0.html#marker - const marker = L.marker( - [lat.toString(), lng.toString()], - {resource, icon} as MarkerOptions - ); - if(this.clustering === null) marker.addTo(this.map); + const marker = L.marker([lat.toString(), lng.toString()], { + resource, + icon, + } as MarkerOptions); + if (this.clustering === null) marker.addTo(this.map); else this.markersCluster.addLayer(marker); marker.on('click', this.dispatchSelect.bind(this)); - if (this.fields !== null) { // show popups only if fields attribute - marker.bindPopup(() => this.getPopupContent(resourceId), { minWidth: 150 }) // re-generate popup solid-display + if (this.fields !== null) { + // show popups only if fields attribute + marker.bindPopup(() => this.getPopupContent(resourceId), { + minWidth: 150, + }); // re-generate popup solid-display } this.markers.push(marker); @@ -157,7 +177,7 @@ export const SolidMap = { * @param resourceId: id of the popup clicked */ getPopupContent(resourceId: string) { - const attributes:{[key:string]: string} = {}; + const attributes: { [key: string]: string } = {}; for (let attr of this.element.attributes) { //copy widget and value attributes @@ -195,7 +215,7 @@ export const SolidMap = { if (!this.map) return; if (this.markersCluster) this.map.removeLayer(this.markersCluster); for (let marker of this.markers) this.map.removeLayer(marker); - if(this.clustering !== null) { + if (this.clustering !== null) { this.markersCluster = L.markerClusterGroup(); this.map.addLayer(this.markersCluster); } @@ -206,7 +226,9 @@ export const SolidMap = { * @param groupName: value of the group */ renderGroup(groupName: string) { - const sanitizedGroupName = encodeURIComponent(groupName.toLowerCase()).replace(/%[0-9A-F]{2}/gi, ''); + const sanitizedGroupName = encodeURIComponent( + groupName.toLowerCase(), + ).replace(/%[0-9A-F]{2}/gi, ''); const div = document.createElement('div'); // used to pass group info to renderDOM div.dataset.groupClass = 'group-' + sanitizedGroupName; return div; @@ -218,15 +240,24 @@ export const SolidMap = { * @param div * @param context */ - renderDOM: trackRenderAsync( - async function(resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string) { + renderDOM: trackRenderAsync(async function ( + resources: object[], + listPostProcessors: PostProcessorRegistry, + div: HTMLElement, + context: string, + ) { const groupClass = div.dataset.groupClass || ''; // get the group class from the useless div element - await Promise.all(resources.map(resource => this.appendChildElt(resource['@id'], groupClass))) + await Promise.all( + resources.map(resource => + this.appendChildElt(resource['@id'], groupClass), + ), + ); this.planReset(); - const nextProcessor = listPostProcessors.shift(); - if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context); - }, "SolidMap:renderDOM" ) + const nextProcessor = listPostProcessors.shift(); + if (nextProcessor) + await nextProcessor(resources, listPostProcessors, div, context); + }, 'SolidMap:renderDOM'), }; -Sib.register(SolidMap); \ No newline at end of file +Sib.register(SolidMap); diff --git a/src/components/solid-member-add.ts b/src/components/solid-member-add.ts index c9615eae..69bce70a 100644 --- a/src/components/solid-member-add.ts +++ b/src/components/solid-member-add.ts @@ -30,11 +30,11 @@ export const SolidMemberAdd = { }, classSubmitButton: { type: String, - default: undefined + default: undefined, }, orderAsc: { type: String, - default: undefined + default: undefined, }, }, initialState: { @@ -61,31 +61,39 @@ export const SolidMemberAdd = { async addMembership() { this.currentMembers.push(JSON.parse(this.dataTargetSrc)); let currentRes = { - "@context": this.context, - "user_set": this.currentMembers - } + '@context': this.context, + user_set: this.currentMembers, + }; return store.patch(currentRes, this.resourceId).then(response => { if (!response) { - console.warn(`Error while adding user ${this.dataTargetSrc} to group ${this.resourceId}`); + console.warn( + `Error while adding user ${this.dataTargetSrc} to group ${this.resourceId}`, + ); return; } this.goToNext(null); - const eventData = { detail: { resource: { "@id": this.dataSrc } }, bubbles: true }; + const eventData = { + detail: { resource: { '@id': this.dataSrc } }, + bubbles: true, + }; this.element.dispatchEvent(new CustomEvent('save', eventData)); this.element.dispatchEvent(new CustomEvent('memberAdded', eventData)); // Deprecated. To remove in 0.15 this.planRender(); - }) + }); }, - validateModal() { // Send method to validationMixin, used by the dialog modal and performAction method + validateModal() { + // Send method to validationMixin, used by the dialog modal and performAction method return this.addMembership(); }, changeSelectedUser(e: Event) { if (!e.target || !(e.target as HTMLElement).firstElementChild) return; //FIXME: disgusting way to get the @id of the autocomplete slimselect widget value - this.dataTargetSrc = ((e.target as HTMLElement).firstElementChild as HTMLSelectElement)?.value; + this.dataTargetSrc = ( + (e.target as HTMLElement).firstElementChild as HTMLSelectElement + )?.value; }, async populate(): Promise<void> { if (!this.resource) return; @@ -99,7 +107,9 @@ export const SolidMemberAdd = { this.currentMembers = [this.currentMembers]; } // In each item in this.currentMembers, I'd like to return only their @id and store it in this.currentMembers - this.currentMembers = this.currentMembers.map(member => { return {"@id": member['@id'] } }); + this.currentMembers = this.currentMembers.map(member => { + return { '@id': member['@id'] }; + }); let button = html` <solid-ac-checker data-src="${this.dataSrc}" @@ -127,7 +137,7 @@ export const SolidMemberAdd = { </solid-ac-checker> `; render(button, this.element); - } + }, }; -Sib.register(SolidMemberAdd); \ No newline at end of file +Sib.register(SolidMemberAdd); diff --git a/src/components/solid-member-delete.ts b/src/components/solid-member-delete.ts index e9dc1260..d26d30b0 100644 --- a/src/components/solid-member-delete.ts +++ b/src/components/solid-member-delete.ts @@ -34,12 +34,12 @@ export const SolidMemberDelete = { callback: function (newValue: string, oldValue: string) { if (newValue !== oldValue) { this.planRender(); - } + } }, }, dataUnknownMember: { type: String, - default: "Given user is not a member of this group", + default: 'Given user is not a member of this group', callback: function (newValue: string, oldValue: string) { if (newValue !== oldValue) this.planRender(); }, @@ -70,13 +70,13 @@ export const SolidMemberDelete = { this.currentMembers = [this.currentMembers]; } - this.currentMembers = this.currentMembers.map((member) => { - return { "@id": member['@id'] }; + this.currentMembers = this.currentMembers.map(member => { + return { '@id': member['@id'] }; }); // Check if current user is member of this group this.isMember = this.currentMembers - ? this.currentMembers.some((member) => member['@id'] === this.dataTargetSrc) + ? this.currentMembers.some(member => member['@id'] === this.dataTargetSrc) : false; }, planRender() { @@ -94,40 +94,44 @@ export const SolidMemberDelete = { this.performAction(); // In validationMixin, method defining what to do according to the present attributes }, async deleteMembership() { - let userSet = this.currentMembers.filter((value) => { + let userSet = this.currentMembers.filter(value => { const userId = value['@id']; - if (userId == this.dataTargetSrc) - return false; + if (userId == this.dataTargetSrc) return false; else return true; }); let currentRes = { - "@context": this.context, - "user_set": userSet - } + '@context': this.context, + user_set: userSet, + }; return store.patch(currentRes, this.dataSrc).then(response => { if (!response) { - console.warn(`Error while removing user ${this.dataTargetSrc} from group ${this.dataSrc}`); + console.warn( + `Error while removing user ${this.dataTargetSrc} from group ${this.dataSrc}`, + ); return; } this.goToNext(null); - const eventData = { detail: { resource: { "@id": this.dataSrc } }, bubbles: true }; + const eventData = { + detail: { resource: { '@id': this.dataSrc } }, + bubbles: true, + }; this.element.dispatchEvent(new CustomEvent('save', eventData)); this.element.dispatchEvent(new CustomEvent('memberRemoved', eventData)); // Deprecated. To remove in 0.15 this.planRender(); - }) + }); }, - validateModal() { // Send method to validationMixin, used by the dialog modal and performAction method + validateModal() { + // Send method to validationMixin, used by the dialog modal and performAction method return this.deleteMembership(); }, update() { this.render(); }, - render: trackRenderAsync( - async function(): Promise<void> { + render: trackRenderAsync(async function (): Promise<void> { // await this.replaceAttributesData(false); await this.populate(); - let button = html`` + let button = html``; if (this.isMember) { button = html` <solid-ac-checker data-src="${this.dataSrc}" @@ -136,16 +140,16 @@ export const SolidMemberDelete = { > <button @click=${this.removeMember.bind(this)}> - ${this.dataLabel || this.t("solid-delete-member.button")} + ${this.dataLabel || this.t('solid-delete-member.button')} </button> ${this.getModalDialog()} </solid-ac-checker> `; } else { - button = html`<span>${this.dataUnknownMember || this.t("solid-member-unknown.span")}</span>`; + button = html`<span>${this.dataUnknownMember || this.t('solid-member-unknown.span')}</span>`; } render(button, this.element); - }, "SolidMemberDelete:render") + }, 'SolidMemberDelete:render'), }; -Sib.register(SolidMemberDelete); \ No newline at end of file +Sib.register(SolidMemberDelete); diff --git a/src/components/solid-membership.ts b/src/components/solid-membership.ts index 3732fde6..01c5eb05 100644 --- a/src/components/solid-membership.ts +++ b/src/components/solid-membership.ts @@ -21,7 +21,7 @@ export const SolidMembership = { }, dataTargetSrc: { type: String, - default: null + default: null, }, dataLeaveLabel: { type: String, @@ -40,7 +40,7 @@ export const SolidMembership = { classSubmitButton: { type: String, default: undefined, - } + }, }, initialState: { renderPlanned: false, @@ -55,10 +55,8 @@ export const SolidMembership = { let currentUserSession = await store.session; if (!currentUserSession) return; - if (!this.dataTargetSrc) - this.userId = await currentUserSession.webId; - else - this.userId = this.dataTargetSrc; + if (!this.dataTargetSrc) this.userId = await currentUserSession.webId; + else this.userId = this.dataTargetSrc; if (!this.userId) return; @@ -74,11 +72,13 @@ export const SolidMembership = { this.currentMembers = [this.currentMembers]; } - this.currentMembers = this.currentMembers.map(member => { return {"@id": member['@id'] } }); + this.currentMembers = this.currentMembers.map(member => { + return { '@id': member['@id'] }; + }); // Check if current user is member of this group this.isMember = this.currentMembers - ? this.currentMembers.some((member) => member['@id'] === this.userId) + ? this.currentMembers.some(member => member['@id'] === this.userId) : false; }, planRender() { @@ -96,46 +96,55 @@ export const SolidMembership = { this.performAction(); // In validationMixin, method defining what to do according to the present attributes }, async joinGroup() { - this.currentMembers.push({"@id": this.userId}); + this.currentMembers.push({ '@id': this.userId }); let currentRes = { - "@context": this.context, - "user_set": this.currentMembers - } + '@context': this.context, + user_set: this.currentMembers, + }; return store.patch(currentRes, this.dataSrc).then(response => { if (!response) { - console.warn(`Error while joining group ${this.dataSrc} for user ${this.userId}`); + console.warn( + `Error while joining group ${this.dataSrc} for user ${this.userId}`, + ); return; } this.goToNext(null); - const eventData = { detail: { resource: { "@id": this.dataSrc } }, bubbles: true }; + const eventData = { + detail: { resource: { '@id': this.dataSrc } }, + bubbles: true, + }; this.element.dispatchEvent(new CustomEvent('save', eventData)); this.element.dispatchEvent(new CustomEvent('memberAdded', eventData)); // Deprecated. To remove in 0.15 this.planRender(); }); }, async leaveGroup() { - let userSet = this.currentMembers.filter((value) => { + let userSet = this.currentMembers.filter(value => { const userId = value['@id']; - if (userId == this.userId) - return false; + if (userId == this.userId) return false; else return true; }); let currentRes = { - "@context": this.context, - "user_set": userSet - } + '@context': this.context, + user_set: userSet, + }; return store.patch(currentRes, this.dataSrc).then(response => { if (!response) { - console.warn(`Error while leaving group ${this.dataSrc} for user ${this.userId}`); + console.warn( + `Error while leaving group ${this.dataSrc} for user ${this.userId}`, + ); return; } this.goToNext(null); - const eventData = { detail: { resource: { "@id": this.dataSrc } }, bubbles: true }; + const eventData = { + detail: { resource: { '@id': this.dataSrc } }, + bubbles: true, + }; this.element.dispatchEvent(new CustomEvent('save', eventData)); this.element.dispatchEvent(new CustomEvent('memberRemoved', eventData)); // Deprecated. To remove in 0.15 this.planRender(); - }) + }); }, switchMembership() { if (this.isMember) { @@ -144,40 +153,39 @@ export const SolidMembership = { return this.joinGroup(); } }, - validateModal() { // Send method to validationMixin, used by the dialog modal and performAction method + validateModal() { + // Send method to validationMixin, used by the dialog modal and performAction method return this.switchMembership(); }, update() { this.render(); }, - render: trackRenderAsync( - async function(): Promise<void> { - await this.populate(); - let button = html``; - if (this.isMember) { - button = html` + render: trackRenderAsync(async function (): Promise<void> { + await this.populate(); + let button = html``; + if (this.isMember) { + button = html` <solid-ac-checker data-src="${this.dataSrc}" permission="acl:Read" - class=${ifDefined(`${this.classSubmitButton ? 'leave ' + this.classSubmitButton: 'leave'}`)} + class=${ifDefined(`${this.classSubmitButton ? 'leave ' + this.classSubmitButton : 'leave'}`)} > - <button @click=${this.changeMembership.bind(this)}>${this.dataLeaveLabel || this.t("solid-leave-group.button")}</button> + <button @click=${this.changeMembership.bind(this)}>${this.dataLeaveLabel || this.t('solid-leave-group.button')}</button> ${this.getModalDialog()} </solid-ac-checker> `; - } else { - button = html` + } else { + button = html` <solid-ac-checker data-src="${this.dataSrc}" permission="acl:Read" - class=${ifDefined(`${this.classSubmitButton ? 'join ' + this.classSubmitButton: 'join'}`)} + class=${ifDefined(`${this.classSubmitButton ? 'join ' + this.classSubmitButton : 'join'}`)} > - <button @click=${this.changeMembership.bind(this)}>${this.dataJoinLabel || this.t("solid-join-group.button")}</button> + <button @click=${this.changeMembership.bind(this)}>${this.dataJoinLabel || this.t('solid-join-group.button')}</button> ${this.getModalDialog()} </solid-ac-checker> `; - } - render(button, this.element); - }, - "SolidMembership:render") + } + render(button, this.element); + }, 'SolidMembership:render'), }; -Sib.register(SolidMembership); \ No newline at end of file +Sib.register(SolidMembership); diff --git a/src/components/solid-table.ts b/src/components/solid-table.ts index e38c081e..3f661eee 100644 --- a/src/components/solid-table.ts +++ b/src/components/solid-table.ts @@ -59,8 +59,11 @@ export const SolidTable = { }, get selectedLines() { if (this.selectable === null) return []; - return (Array.from(this.element.querySelectorAll('input[data-selection]:checked')) as Element[]) - .map(e => e?.closest('[data-resource]')?.getAttribute('data-resource')); + return ( + Array.from( + this.element.querySelectorAll('input[data-selection]:checked'), + ) as Element[] + ).map(e => e?.closest('[data-resource]')?.getAttribute('data-resource')); }, /** * Select all lines @@ -68,7 +71,11 @@ export const SolidTable = { */ selectAll(e) { if (this.selectable === null) return; - for (const checkbox of Array.from(this.element.querySelectorAll('input[data-selection]') as HTMLInputElement[])) { + for (const checkbox of Array.from( + this.element.querySelectorAll( + 'input[data-selection]', + ) as HTMLInputElement[], + )) { checkbox.checked = e.target.checked; } }, @@ -77,7 +84,11 @@ export const SolidTable = { */ unselectAll(): void { if (this.selectable === null) return; - for (const checkbox of Array.from(this.element.querySelectorAll('input[data-selection]') as HTMLInputElement[])) { + for (const checkbox of Array.from( + this.element.querySelectorAll( + 'input[data-selection]', + ) as HTMLInputElement[], + )) { checkbox.checked = false; } }, @@ -88,7 +99,9 @@ export const SolidTable = { selectLines(lines: string[]) { if (this.selectable === null || lines.length === 0) return; for (const line of lines) { - const checkbox = this.element.querySelector(`[data-resource="${line}"] input[data-selection]`); + const checkbox = this.element.querySelector( + `[data-resource="${line}"] input[data-selection]`, + ); if (checkbox) checkbox.checked = true; } }, @@ -99,11 +112,13 @@ export const SolidTable = { */ async createCellWidget(field: string, resource: Resource) { // if regular widget - if (!this.element.hasAttribute('editable-' + field)) return this.createWidgetTemplate(field, resource, true); + if (!this.element.hasAttribute('editable-' + field)) + return this.createWidgetTemplate(field, resource, true); // if editable widget const attributes = {}; - const formWidgetAttributes = [ // attributes to give to the form widget + const formWidgetAttributes = [ + // attributes to give to the form widget 'range', 'enum', 'placeholder', @@ -115,16 +130,19 @@ export const SolidTable = { 'max', 'pattern', 'title', - 'widget' + 'widget', ]; - for (let attr of formWidgetAttributes) this.addToAttributes(`${attr}-${field}`, `${attr}-${field}`, attributes) + for (let attr of formWidgetAttributes) + this.addToAttributes(`${attr}-${field}`, `${attr}-${field}`, attributes); - const formAttributes = [ // attributes to give to the form + const formAttributes = [ + // attributes to give to the form 'class', 'submit-button', - 'next' + 'next', ]; - for (let attr of formAttributes) this.addToAttributes(`${attr}-${field}`, attr, attributes) + for (let attr of formAttributes) + this.addToAttributes(`${attr}-${field}`, attr, attributes); return html` <solid-form @@ -144,9 +162,9 @@ export const SolidTable = { let template = html` <tr> ${this.selectable !== null ? html`<th><input type="checkbox" @change="${this.selectAll.bind(this)}" /></th>` : ''} - ${fields.map((field: string) => html`<th>${this.element.hasAttribute('label-'+field) ? this.element.getAttribute('label-'+field) : field}</th>`)} + ${fields.map((field: string) => html`<th>${this.element.hasAttribute('label-' + field) ? this.element.getAttribute('label-' + field) : field}</th>`)} </tr> - ` + `; return template; }, /** @@ -161,7 +179,7 @@ export const SolidTable = { ${this.selectable !== null ? html`<td><input type="checkbox" data-selection /></td>` : ''} ${fields.map((field: string) => html`<td>${until(this.createCellWidget(field, resource))}</td>`)} </tr> - ` + `; return template; }, @@ -185,7 +203,7 @@ export const SolidTable = { * @param div * @param context */ - renderDOM: trackRenderAsync(async function( + renderDOM: trackRenderAsync(async function ( resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, @@ -194,7 +212,7 @@ export const SolidTable = { const selectedLines = [...this.selectedLines]; // save selected lines before moving them const fields = await this.getFields(); const childTemplates = await Promise.all( - resources.map(r => r ? this.getChildTemplate(r['@id'], fields) : null) + resources.map(r => (r ? this.getChildTemplate(r['@id'], fields) : null)), ); const template = html`${this.header !== null ? this.getHeader(fields) : ''}${childTemplates}`; // create a child template for each resource render(template, div); @@ -205,13 +223,8 @@ export const SolidTable = { const nextProcessor = listPostProcessors.shift(); if (nextProcessor) - await nextProcessor( - resources, - listPostProcessors, - div, - context - ); - }, "SolidTable:renderDom"), + await nextProcessor(resources, listPostProcessors, div, context); + }, 'SolidTable:renderDom'), }; Sib.register(SolidTable); diff --git a/src/components/solid-widget.ts b/src/components/solid-widget.ts index e8d30db4..98a4a6b9 100644 --- a/src/components/solid-widget.ts +++ b/src/components/solid-widget.ts @@ -13,35 +13,33 @@ export const SolidWidget = { attributes: { name: { type: String, - default: "", - required: true - } + default: '', + required: true, + }, }, attached(): void { if (!this.name) return; const template = this.template; const newWidget = { name: this.name, - use: [ - BaseWidgetMixin, - StoreMixin, - FormMixin, - ActionMixin - ], + use: [BaseWidgetMixin, StoreMixin, FormMixin, ActionMixin], attributes: { label: { type: String, default: '', callback: function (newValue: string) { this.addToAttributes(newValue, 'label'); - } + }, }, }, get template() { - return () => this.evalTemplate(template).then((tpl: string) => html`${unsafeHTML(tpl)}`) + return () => + this.evalTemplate(template).then( + (tpl: string) => html`${unsafeHTML(tpl)}`, + ); }, evalTemplate(template: string) { - const tpl = evalTemplateString(template, { + const tpl = evalTemplateString(template, { name: this.name, value: this.value || this.resource || '', src: this.src, @@ -55,13 +53,15 @@ export const SolidWidget = { }, // For form widgets, handle nested solid-form getValueFromElement(element: any) { - if (element.tagName === "SOLID-FORM") return element.component.value; // nested solid-form + if (element.tagName === 'SOLID-FORM') + return element.component.value; // nested solid-form else if (element.component) return element.component.getValue(); // form widget return element.value; // input }, - updateDOM() { // override StoreMixin method to launch render when resource fetched + updateDOM() { + // override StoreMixin method to launch render when resource fetched this.planRender(); - } + }, }; Sib.register(newWidget); // and register component @@ -72,7 +72,7 @@ export const SolidWidget = { get childTemplate(): string | null { const child = this.element.querySelector('template[data-range]'); return child ? child.innerHTML : null; - } + }, }; -Sib.register(SolidWidget); \ No newline at end of file +Sib.register(SolidWidget); diff --git a/src/index.ts b/src/index.ts index 680d5358..8c7da04e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import "./libs/polyfills.js"; +import './libs/polyfills.js'; // Components import { SolidDisplay } from './components/solid-display'; import { SolidForm } from './components/solid-form'; @@ -65,7 +65,6 @@ export { SolidMembership, SolidMemberDelete, SolidMemberAdd, - // Mixins CounterMixin, FederationMixin, @@ -81,14 +80,12 @@ export { TranslationMixin, ValidationMixin, WidgetMixin, - // New widgets system AttributeMixins, CallbackMixins, TemplateAdditionMixins, TemplatesDependenciesMixins, Templates, - // Libs store, Sib, @@ -98,11 +95,10 @@ export { BaseWidgetMixin, Helpers, baseContext, - // lit-html html, render, ifDefined, until, - unsafeHTML -} \ No newline at end of file + unsafeHTML, +}; diff --git a/src/libs/Component.ts b/src/libs/Component.ts index e22ae00b..198942cb 100644 --- a/src/libs/Component.ts +++ b/src/libs/Component.ts @@ -1,5 +1,5 @@ -import { Profiler } from "../logger"; -import type { ComponentInterface } from "./interfaces.js"; +import { Profiler } from '../logger'; +import type { ComponentInterface } from './interfaces.js'; export abstract class Component implements ComponentInterface { public element: HTMLElement; @@ -14,5 +14,5 @@ export abstract class Component implements ComponentInterface { attached() {} detached() {} - attributesCallback(_key: string, _value: any, _oldValue: any):void {} + attributesCallback(_key: string, _value: any, _oldValue: any): void {} } diff --git a/src/libs/ComponentFactory.ts b/src/libs/ComponentFactory.ts index 3f0228ea..b8cbd4da 100644 --- a/src/libs/ComponentFactory.ts +++ b/src/libs/ComponentFactory.ts @@ -5,20 +5,38 @@ import type { AttributesDefinitionInterface, ComponentConstructorInterface, ArrayOfHooksInterface, - AccessorStaticInterface + AccessorStaticInterface, } from './interfaces'; export class ComponentFactory { - public static build(component: MixinStaticInterface): ComponentConstructorInterface { - const { initialState, attributes, methods, hooks, accessors, name } = Compositor.merge(component, Compositor.mergeMixin(component)); + public static build( + component: MixinStaticInterface, + ): ComponentConstructorInterface { + const { initialState, attributes, methods, hooks, accessors, name } = + Compositor.merge(component, Compositor.mergeMixin(component)); let componentConstructor = class extends Component {}; - componentConstructor = ComponentFactory.bindInitialState(componentConstructor, initialState); - componentConstructor = ComponentFactory.bindAttributes(componentConstructor, attributes); - componentConstructor = ComponentFactory.bindMethods(componentConstructor, methods); - componentConstructor = ComponentFactory.bindAccessors(componentConstructor, accessors); - componentConstructor = ComponentFactory.bindHooks(componentConstructor, hooks); + componentConstructor = ComponentFactory.bindInitialState( + componentConstructor, + initialState, + ); + componentConstructor = ComponentFactory.bindAttributes( + componentConstructor, + attributes, + ); + componentConstructor = ComponentFactory.bindMethods( + componentConstructor, + methods, + ); + componentConstructor = ComponentFactory.bindAccessors( + componentConstructor, + accessors, + ); + componentConstructor = ComponentFactory.bindHooks( + componentConstructor, + hooks, + ); Reflect.defineProperty(componentConstructor, 'name', { value: name, @@ -27,7 +45,10 @@ export class ComponentFactory { return componentConstructor; } - protected static bindInitialState(componentConstructor: ComponentConstructorInterface, initialState: object | undefined):any { + protected static bindInitialState( + componentConstructor: ComponentConstructorInterface, + initialState: object | undefined, + ): any { if (initialState) { Reflect.ownKeys(initialState).forEach(key => { Reflect.defineProperty(componentConstructor.prototype, key, { @@ -41,9 +62,14 @@ export class ComponentFactory { return componentConstructor; } - protected static bindAttributes(componentConstructor: ComponentConstructorInterface, attributes: AttributesDefinitionInterface | undefined): ComponentConstructorInterface { + protected static bindAttributes( + componentConstructor: ComponentConstructorInterface, + attributes: AttributesDefinitionInterface | undefined, + ): ComponentConstructorInterface { if (attributes) { - const attributesList = Reflect.ownKeys(attributes).map(key => String(key)); + const attributesList = Reflect.ownKeys(attributes).map(key => + String(key), + ); const attributesCallback = {}; attributesList.forEach(key => { @@ -75,7 +101,9 @@ export class ComponentFactory { break; } - const attribute = key.replace(/([a-z0-9])([A-Z0-9])/g, '$1-$2').toLowerCase(); + const attribute = key + .replace(/([a-z0-9])([A-Z0-9])/g, '$1-$2') + .toLowerCase(); Reflect.defineProperty(componentConstructor.prototype, key, { enumerable: true, @@ -110,39 +138,59 @@ export class ComponentFactory { }); Reflect.defineProperty(componentConstructor, 'observedAttributes', { - get: () => attributesList.map(attr => attr.replace(/([a-z0-9])([A-Z0-9])/g, '$1-$2').toLowerCase()), + get: () => + attributesList.map(attr => + attr.replace(/([a-z0-9])([A-Z0-9])/g, '$1-$2').toLowerCase(), + ), }); - Reflect.defineProperty(componentConstructor.prototype, 'attributesCallback', { - value: function(key, newValue, oldValue) { - if (key in attributesCallback) { - Reflect.apply(attributesCallback[key], this, [newValue, oldValue]); - } - } - }); + Reflect.defineProperty( + componentConstructor.prototype, + 'attributesCallback', + { + value: function (key, newValue, oldValue) { + if (key in attributesCallback) { + Reflect.apply(attributesCallback[key], this, [ + newValue, + oldValue, + ]); + } + }, + }, + ); - Reflect.defineProperty(componentConstructor.prototype, 'attributesCallback', attributesCallback); + Reflect.defineProperty( + componentConstructor.prototype, + 'attributesCallback', + attributesCallback, + ); } return componentConstructor; } - protected static bindAccessors(componentConstructor: ComponentConstructorInterface, accessors: AccessorStaticInterface): ComponentConstructorInterface { + protected static bindAccessors( + componentConstructor: ComponentConstructorInterface, + accessors: AccessorStaticInterface, + ): ComponentConstructorInterface { if (accessors) { Object.keys(accessors).forEach(property => { Reflect.defineProperty(componentConstructor.prototype, property, { get: function () { - return Reflect.apply(accessors[property].get, this, []) + return Reflect.apply(accessors[property].get, this, []); }, set: function (value) { - return Reflect.apply(accessors[property].set, this, [value]) - } + return Reflect.apply(accessors[property].set, this, [value]); + }, }); }); } return componentConstructor; } - protected static bindMethods(componentConstructor: ComponentConstructorInterface, methods: Map<string, Function>): ComponentConstructorInterface { + protected static bindMethods( + componentConstructor: ComponentConstructorInterface, + methods: Map<string, Function>, + ): ComponentConstructorInterface { methods.forEach((method, methodName: string) => { Reflect.defineProperty(componentConstructor.prototype, methodName, { value: function (...args) { @@ -153,9 +201,12 @@ export class ComponentFactory { return componentConstructor; } - protected static bindHooks(componentConstructor: ComponentConstructorInterface, hooks: ArrayOfHooksInterface): ComponentConstructorInterface { + protected static bindHooks( + componentConstructor: ComponentConstructorInterface, + hooks: ArrayOfHooksInterface, + ): ComponentConstructorInterface { Reflect.defineProperty(componentConstructor.prototype, 'created', { - value: function() { + value: function () { hooks.created.forEach(hook => { Reflect.apply(hook, this, []); }); @@ -163,7 +214,7 @@ export class ComponentFactory { }); Reflect.defineProperty(componentConstructor.prototype, 'attached', { - value: function() { + value: function () { hooks.attached.forEach(hook => { Reflect.apply(hook, this, []); }); @@ -171,7 +222,7 @@ export class ComponentFactory { }); Reflect.defineProperty(componentConstructor.prototype, 'detached', { - value: function() { + value: function () { hooks.detached.forEach(hook => { Reflect.apply(hook, this, []); }); diff --git a/src/libs/Compositor.ts b/src/libs/Compositor.ts index 829e2698..945b18a2 100644 --- a/src/libs/Compositor.ts +++ b/src/libs/Compositor.ts @@ -3,32 +3,34 @@ import type { ComponentStaticInterface, AttributesDefinitionInterface, ArrayOfHooksInterface, - AccessorStaticInterface + AccessorStaticInterface, } from './interfaces'; const HOOKS = ['created', 'attached', 'detached']; -const API = [ - 'name', - 'use', - 'attributes', - 'initialState', - ...HOOKS, -]; +const API = ['name', 'use', 'attributes', 'initialState', ...HOOKS]; export class Compositor { - public static merge(component: MixinStaticInterface, mixins: MixinStaticInterface[]): ComponentStaticInterface { + public static merge( + component: MixinStaticInterface, + mixins: MixinStaticInterface[], + ): ComponentStaticInterface { return { name: component.name, - attributes: Compositor.mergeAttributes([ component, ...mixins ]), - initialState: Compositor.mergeInitialState([ component, ...mixins ]), - methods: Compositor.mergeMethods([ component, ...mixins]), - accessors: Compositor.mergeAccessors([ component, ...mixins]), - hooks: Compositor.mergeHooks([ component, ...mixins ]), + attributes: Compositor.mergeAttributes([component, ...mixins]), + initialState: Compositor.mergeInitialState([component, ...mixins]), + methods: Compositor.mergeMethods([component, ...mixins]), + accessors: Compositor.mergeAccessors([component, ...mixins]), + hooks: Compositor.mergeHooks([component, ...mixins]), }; } - public static mergeMixin(component: MixinStaticInterface): MixinStaticInterface[] { - function deepMergeMixin(mixinAccumulator: Map<MixinStaticInterface, MixinStaticInterface>, currentMixin: MixinStaticInterface) { + public static mergeMixin( + component: MixinStaticInterface, + ): MixinStaticInterface[] { + function deepMergeMixin( + mixinAccumulator: Map<MixinStaticInterface, MixinStaticInterface>, + currentMixin: MixinStaticInterface, + ) { const { use: currentMixins } = currentMixin; if (currentMixins) { currentMixins.forEach(mix => { @@ -48,12 +50,14 @@ export class Compositor { return Array.from(mixins.values()); } - public static mergeAttributes(mixins: MixinStaticInterface[]): AttributesDefinitionInterface { + public static mergeAttributes( + mixins: MixinStaticInterface[], + ): AttributesDefinitionInterface { let attributes = {}; mixins.forEach(mixin => { if (!!mixin.attributes) { - attributes = {...mixin.attributes, ...attributes }; + attributes = { ...mixin.attributes, ...attributes }; } }); @@ -65,29 +69,28 @@ export class Compositor { mixins.forEach(mixin => { if (!!mixin.initialState) { - initialState = {...mixin.initialState, ...initialState }; + initialState = { ...mixin.initialState, ...initialState }; } }); return initialState; } - public static mergeHooks(mixins: MixinStaticInterface[]): ArrayOfHooksInterface { + public static mergeHooks( + mixins: MixinStaticInterface[], + ): ArrayOfHooksInterface { const hooks = { created: [], attached: [], detached: [], }; - mixins - .reverse() - .forEach(mixin => { - HOOKS.forEach(hookName => { - if(!!mixin[hookName] && typeof mixin[hookName] === 'function') { - hooks[hookName].push(mixin[hookName]); - } - }); + mixins.reverse().forEach(mixin => { + HOOKS.forEach(hookName => { + if (!!mixin[hookName] && typeof mixin[hookName] === 'function') { + hooks[hookName].push(mixin[hookName]); + } }); - + }); return hooks; } @@ -96,14 +99,14 @@ export class Compositor { const methods = new Map(); mixins.reverse().forEach(mixin => { - const keys = Reflect - .ownKeys(mixin) - .filter(key => ( + const keys = Reflect.ownKeys(mixin).filter( + key => typeof key === 'string' && API.indexOf(key) < 0 && !Object.getOwnPropertyDescriptor(mixin, key)!.get && !Object.getOwnPropertyDescriptor(mixin, key)!.set && - typeof mixin[key] === 'function')); + typeof mixin[key] === 'function', + ); keys.forEach(key => { methods.set(key, mixin[key]); @@ -112,21 +115,32 @@ export class Compositor { return methods; } - public static mergeAccessors(mixins: MixinStaticInterface[]): AccessorStaticInterface { + public static mergeAccessors( + mixins: MixinStaticInterface[], + ): AccessorStaticInterface { const accessors = {}; mixins.reverse().forEach(mixin => { - Reflect - .ownKeys(mixin) - .filter(key => ( - typeof key === 'string' && - API.indexOf(key) < 0 && - (Object.getOwnPropertyDescriptor(mixin, key)!.get || Object.getOwnPropertyDescriptor(mixin, key)!.set) - )) - .forEach(prop => { - accessors[prop] = { ...accessors[prop] }; - if (Reflect.getOwnPropertyDescriptor(mixin, prop)!.get) accessors[prop].get = Reflect.getOwnPropertyDescriptor(mixin, prop)!.get; - if (Reflect.getOwnPropertyDescriptor(mixin, prop)!.set) accessors[prop].set = Reflect.getOwnPropertyDescriptor(mixin, prop)!.set; - }); + Reflect.ownKeys(mixin) + .filter( + key => + typeof key === 'string' && + API.indexOf(key) < 0 && + (Object.getOwnPropertyDescriptor(mixin, key)!.get || + Object.getOwnPropertyDescriptor(mixin, key)!.set), + ) + .forEach(prop => { + accessors[prop] = { ...accessors[prop] }; + if (Reflect.getOwnPropertyDescriptor(mixin, prop)!.get) + accessors[prop].get = Reflect.getOwnPropertyDescriptor( + mixin, + prop, + )!.get; + if (Reflect.getOwnPropertyDescriptor(mixin, prop)!.set) + accessors[prop].set = Reflect.getOwnPropertyDescriptor( + mixin, + prop, + )!.set; + }); }); return accessors; } diff --git a/src/libs/PostProcessorRegistry.ts b/src/libs/PostProcessorRegistry.ts index e0f33197..bac22efa 100644 --- a/src/libs/PostProcessorRegistry.ts +++ b/src/libs/PostProcessorRegistry.ts @@ -1,81 +1,79 @@ export type PostProcessor = { - name: string; - fn: Function; + name: string; + fn: Function; }; export class PostProcessorRegistry { - private currentPostProcessors: PostProcessor[]; + private currentPostProcessors: PostProcessor[]; - constructor(currentPostProcessors: PostProcessor[] = []) { - this.currentPostProcessors = [...currentPostProcessors]; - } + constructor(currentPostProcessors: PostProcessor[] = []) { + this.currentPostProcessors = [...currentPostProcessors]; + } - public attach(callback: Function, callbackName: string): void { - this.currentPostProcessors.push({ name: callbackName, fn: callback }); - } + public attach(callback: Function, callbackName: string): void { + this.currentPostProcessors.push({ name: callbackName, fn: callback }); + } - public getPostProcessors(): PostProcessor[] { - return this.currentPostProcessors; - } + public getPostProcessors(): PostProcessor[] { + return this.currentPostProcessors; + } - public printCurrentCallbacks(): void { - if (this.currentPostProcessors.length === 0) { - console.log('No post-processors registered.'); - } else { - console.log('Registered post-processors:'); - this.currentPostProcessors.forEach(proc => { - console.log(`- ${proc.name}`); - }); - } + public printCurrentCallbacks(): void { + if (this.currentPostProcessors.length === 0) { + console.log('No post-processors registered.'); + } else { + console.log('Registered post-processors:'); + this.currentPostProcessors.forEach(proc => { + console.log(`- ${proc.name}`); + }); } + } - public getFormattedCallbacks(): string { - if (this.currentPostProcessors.length === 0) { - return 'No post-processors registered.'; - } else { - let formattedText = 'Registered post-processors:\n'; - this.currentPostProcessors.forEach(proc => { - formattedText += `- ${proc.name}\n`; - }); - return formattedText.trim(); - } + public getFormattedCallbacks(): string { + if (this.currentPostProcessors.length === 0) { + return 'No post-processors registered.'; + } else { + let formattedText = 'Registered post-processors:\n'; + this.currentPostProcessors.forEach(proc => { + formattedText += `- ${proc.name}\n`; + }); + return formattedText.trim(); } + } - static printFormattedCallbacks(currentPostProcessors: PostProcessor[]): string { - if (currentPostProcessors.length === 0) { - return 'No post-processors registered.'; - } else { - let formattedText = 'Registered post-processors:\n'; - currentPostProcessors.forEach(proc => { - formattedText += `- ${proc.name}\n`; - }); - return formattedText.trim(); - } + static printFormattedCallbacks( + currentPostProcessors: PostProcessor[], + ): string { + if (currentPostProcessors.length === 0) { + return 'No post-processors registered.'; + } else { + let formattedText = 'Registered post-processors:\n'; + currentPostProcessors.forEach(proc => { + formattedText += `- ${proc.name}\n`; + }); + return formattedText.trim(); } + } - public whichCallbackExecutedNext(): string { - if (this.currentPostProcessors.length === 0) { - return 'No post-processors registered.'; - } else { - return `Next post-processor to be executed is: ${this.currentPostProcessors[0].name}`; - - } + public whichCallbackExecutedNext(): string { + if (this.currentPostProcessors.length === 0) { + return 'No post-processors registered.'; + } else { + return `Next post-processor to be executed is: ${this.currentPostProcessors[0].name}`; } + } - public deepCopy(): PostProcessorRegistry { - const copy = new PostProcessorRegistry(this.currentPostProcessors); - return copy; - } + public deepCopy(): PostProcessorRegistry { + const copy = new PostProcessorRegistry(this.currentPostProcessors); + return copy; + } - public shift(): Function | undefined { - const res = this.currentPostProcessors.shift(); + public shift(): Function | undefined { + const res = this.currentPostProcessors.shift(); - if (res) { - return res.fn; - } - return undefined; + if (res) { + return res.fn; } - - - -} \ No newline at end of file + return undefined; + } +} diff --git a/src/libs/Sib.ts b/src/libs/Sib.ts index c11e6804..419c721c 100644 --- a/src/libs/Sib.ts +++ b/src/libs/Sib.ts @@ -1,54 +1,59 @@ -import { ComponentFactory } from "./ComponentFactory.js"; -import { defineComponent } from "./helpers.js"; +import { ComponentFactory } from './ComponentFactory.js'; +import { defineComponent } from './helpers.js'; import type { - ComponentConstructorInterface, - ComponentInterface, - MixinStaticInterface -} from "./interfaces.js"; + ComponentConstructorInterface, + ComponentInterface, + MixinStaticInterface, +} from './interfaces.js'; export class Sib { - public static register(componentDefinition: MixinStaticInterface):void { - const component = ComponentFactory.build(componentDefinition); - const cls = this.toElement(component); - defineComponent(component.name, cls); - } - - protected static toElement(component: ComponentConstructorInterface): typeof HTMLElement { - return class extends HTMLElement { - private _component: ComponentInterface | null = null; - - constructor() { - super(); - this.component = new component(this); - this.component.created(); - } - - get component(): ComponentInterface { - if (this._component === null) { - throw new Error('No component found'); - } - return this._component; - } - set component(component: ComponentInterface) { - this._component = component; - } - - static get observedAttributes() { - return (<any>component).observedAttributes; - } - - attributeChangedCallback(name, oldValue, newValue) { - const attr = name.replace(/([a-z0-9])-([a-z0-9])/g, (_c, p1, p2) => `${p1}${p2.toUpperCase()}`); - this.component.attributesCallback(attr, newValue, oldValue); - } - - connectedCallback() { - this.component.attached(); - } - - disconnectedCallback() { - this.component.detached(); - } + public static register(componentDefinition: MixinStaticInterface): void { + const component = ComponentFactory.build(componentDefinition); + const cls = this.toElement(component); + defineComponent(component.name, cls); + } + + protected static toElement( + component: ComponentConstructorInterface, + ): typeof HTMLElement { + return class extends HTMLElement { + private _component: ComponentInterface | null = null; + + constructor() { + super(); + this.component = new component(this); + this.component.created(); + } + + get component(): ComponentInterface { + if (this._component === null) { + throw new Error('No component found'); } - } + return this._component; + } + set component(component: ComponentInterface) { + this._component = component; + } + + static get observedAttributes() { + return (<any>component).observedAttributes; + } + + attributeChangedCallback(name, oldValue, newValue) { + const attr = name.replace( + /([a-z0-9])-([a-z0-9])/g, + (_c, p1, p2) => `${p1}${p2.toUpperCase()}`, + ); + this.component.attributesCallback(attr, newValue, oldValue); + } + + connectedCallback() { + this.component.attached(); + } + + disconnectedCallback() { + this.component.detached(); + } + }; + } } diff --git a/src/libs/async-query-selector-types.ts b/src/libs/async-query-selector-types.ts index 5bfd0121..464e1532 100644 --- a/src/libs/async-query-selector-types.ts +++ b/src/libs/async-query-selector-types.ts @@ -2,50 +2,50 @@ export type AsyncQuerySelectorType = { <K extends keyof HTMLElementTagNameMap>( selectors: K, parent?: ParentNode, - ): Promise<HTMLElementTagNameMap[K]> + ): Promise<HTMLElementTagNameMap[K]>; <K extends keyof SVGElementTagNameMap>( selectors: K, parent?: ParentNode, - ): Promise<SVGElementTagNameMap[K]> + ): Promise<SVGElementTagNameMap[K]>; //@ts-ignore <K extends keyof MathMLElementTagNameMap>( selectors: K, parent?: ParentNode, - //@ts-ignore - ): Promise<MathMLElementTagNameMap[K]> + //@ts-ignore + ): Promise<MathMLElementTagNameMap[K]>; /** @deprecated */ <K extends keyof HTMLElementDeprecatedTagNameMap>( selectors: K, parent?: ParentNode, - ): Promise<HTMLElementDeprecatedTagNameMap[K]> + ): Promise<HTMLElementDeprecatedTagNameMap[K]>; <E extends Element = Element>( selectors: string, parent?: ParentNode, - ): Promise<E> -} + ): Promise<E>; +}; export type AsyncQuerySelectorAllType = { <K extends keyof HTMLElementTagNameMap>( selectors: K, parent?: ParentNode, - ): AsyncIterable<HTMLElementTagNameMap[K]> + ): AsyncIterable<HTMLElementTagNameMap[K]>; <K extends keyof SVGElementTagNameMap>( selectors: K, parent?: ParentNode, - ): AsyncIterable<SVGElementTagNameMap[K]> + ): AsyncIterable<SVGElementTagNameMap[K]>; //@ts-ignore <K extends keyof MathMLElementTagNameMap>( selectors: K, parent?: ParentNode, - //@ts-ignore - ): AsyncIterable<MathMLElementTagNameMap[K]> + //@ts-ignore + ): AsyncIterable<MathMLElementTagNameMap[K]>; /** @deprecated */ <K extends keyof HTMLElementDeprecatedTagNameMap>( selectors: K, parent?: ParentNode, - ): AsyncIterable<HTMLElementDeprecatedTagNameMap[K]> + ): AsyncIterable<HTMLElementDeprecatedTagNameMap[K]>; <E extends Element = Element>( selectors: string, parent?: ParentNode, - ): AsyncIterable<E> -} + ): AsyncIterable<E>; +}; diff --git a/src/libs/filter.ts b/src/libs/filter.ts index 6082d904..091148f8 100644 --- a/src/libs/filter.ts +++ b/src/libs/filter.ts @@ -1,5 +1,10 @@ -import { parseFieldsString, findClosingBracketMatchIndex, compare, uniqID } from "./helpers"; -import type { Query, SearchQuery } from "./interfaces"; +import { + parseFieldsString, + findClosingBracketMatchIndex, + compare, + uniqID, +} from './helpers'; +import type { Query, SearchQuery } from './interfaces'; /** * Check if the field is a set @@ -11,7 +16,7 @@ const isSet = (field: string, fields: string): boolean => { if (!fields) return false; let foundSets = fields.match(getSetRegexp(field)); return foundSets ? foundSets.length > 0 : false; -} +}; /** * Get the list of fields in the set * @param field - set name to get @@ -21,14 +26,15 @@ const isSet = (field: string, fields: string): boolean => { const getSet = (field: string, fields: string): string[] => { const setString = fields.match(getSetRegexp(field)); if (!setString) return []; - const firstSetBracket = fields.indexOf(setString[0]) + (setString[0].length) - 1; + const firstSetBracket = + fields.indexOf(setString[0]) + setString[0].length - 1; const lastSetBracket = findClosingBracketMatchIndex(fields, firstSetBracket); const set = fields.substring(firstSetBracket + 1, lastSetBracket); return parseFieldsString(set); -} +}; const getSetRegexp = (field: string) => { - return new RegExp(`(^|\\,|\\(|\\s)\\s*${field}\\s*\\(`, 'g') -} + return new RegExp(`(^|\\,|\\(|\\s)\\s*${field}\\s*\\(`, 'g'); +}; /** * Check if the field is a special search field * @param field - field to test @@ -37,7 +43,7 @@ const getSetRegexp = (field: string) => { */ const isSearchField = (field: string, searchForm: any) => { return searchForm.hasAttribute('search-' + field); -} +}; /** * Get the fields targetted by a search field * @param field - search field to get @@ -46,7 +52,7 @@ const isSearchField = (field: string, searchForm: any) => { */ const getSearchField = (field: string, searchForm: any): string[] => { return parseFieldsString(searchForm.getAttribute('search-' + field)); -} +}; /** * Throw or simply return value @@ -58,7 +64,7 @@ const orThrow = (throwOn: boolean | undefined, ret: boolean) => { if (throwOn === true && ret) throw true; if (throwOn === false && !ret) throw false; return ret; -} +}; /** * Compare a value to the query @@ -67,14 +73,22 @@ const orThrow = (throwOn: boolean | undefined, ret: boolean) => { * @param throwOn - should function throw error on True or False * @returns true if value matches, throw error otherwise */ -const matchValue = async (val: any, query: Query, throwOn?: boolean): Promise<boolean> => { +const matchValue = async ( + val: any, + query: Query, + throwOn?: boolean, +): Promise<boolean> => { const subject = await val; if (subject == null && query.value === '') return orThrow(throwOn, true); // filter not set and subject not existing -> ignore filter - if (subject == null) return orThrow(throwOn, false); // return false; // property does not exist on resource - if (query.list) { // Filter on a container - if(query.value.length === 0) return orThrow(throwOn, true); - for(const v of query.value) { - if (await matchValue(subject, { type: query.type, value: v, list: false })) { // do not throw here, we need the result + if (subject == null) return orThrow(throwOn, false); // return false; // property does not exist on resource + if (query.list) { + // Filter on a container + if (query.value.length === 0) return orThrow(throwOn, true); + for (const v of query.value) { + if ( + await matchValue(subject, { type: query.type, value: v, list: false }) + ) { + // do not throw here, we need the result return orThrow(throwOn, true); } } @@ -83,14 +97,14 @@ const matchValue = async (val: any, query: Query, throwOn?: boolean): Promise<bo if (subject.isContainer?.()) { let ret: any = Promise.resolve(query.value === ''); // if no query, return a match for (const value of subject['ldp:contains']) { - ret = await ret || await matchValue(value, query); // do not throw here, we need the result + ret = (await ret) || (await matchValue(value, query)); // do not throw here, we need the result if (ret) return orThrow(throwOn, true); } return orThrow(throwOn, await ret); - } else if(Array.isArray(subject)) { + } else if (Array.isArray(subject)) { let ret: any = Promise.resolve(query.value === ''); // if no query, return a match for (const value of subject) { - ret = await ret || await matchValue(value, query); // do not throw here, we need the result + ret = (await ret) || (await matchValue(value, query)); // do not throw here, we need the result if (ret) { return true; } @@ -99,7 +113,7 @@ const matchValue = async (val: any, query: Query, throwOn?: boolean): Promise<bo } return orThrow(throwOn, compare[query.type](subject, query.value)); -} +}; /** * Cache properties of a filter to avoid repeated parsing @@ -112,15 +126,17 @@ const cacheFieldsProps = ( cacheKey: string, filter: string, fields: string, - searchForm: any + searchForm: any, ) => { if (!window.cachePropsSearchFilter[cacheKey]) { window.cachePropsSearchFilter[cacheKey] = { setFields: isSet(filter, fields) ? getSet(filter, fields) : null, - setSearchFields: isSearchField(filter, searchForm) ? getSearchField(filter, searchForm) : null - } + setSearchFields: isSearchField(filter, searchForm) + ? getSearchField(filter, searchForm) + : null, + }; } -} +}; /** * Allow to traverse a multi-depth path to filter on resources of a given type @@ -129,7 +145,11 @@ const cacheFieldsProps = ( * @param targetedType The type of resources we are looking for * @returns The list of all resources ids found of given type */ -const traversePath = async (resource: object, path: string[], targetedType: string): Promise<object[]> => { +const traversePath = async ( + resource: object, + path: string[], + targetedType: string, +): Promise<object[]> => { let result: object[] = []; let currentRes: any; let remainingPath: string[] = path; @@ -140,7 +160,7 @@ const traversePath = async (resource: object, path: string[], targetedType: stri currentRes = await resource[path[0]]; const lastPath1El = path.shift(); - if(lastPath1El) remainingPath = path; + if (lastPath1El) remainingPath = path; if (currentRes && remainingPath.length > 1) { result = await traversePath(currentRes, remainingPath, targetedType); // Await the result of traversePath @@ -156,9 +176,9 @@ const traversePath = async (resource: object, path: string[], targetedType: stri } if (!Array.isArray(targetsRes)) targetsRes = [targetsRes]; - for(const targetRes of targetsRes) { - if (!result.some(item => item["@id"] === targetRes["@id"])) { - result.push({"@id": targetRes["@id"]}); + for (const targetRes of targetsRes) { + if (!result.some(item => item['@id'] === targetRes['@id'])) { + result.push({ '@id': targetRes['@id'] }); } } } @@ -170,8 +190,7 @@ const traversePath = async (resource: object, path: string[], targetedType: stri } // console.log(`TraversePath result for ${resource['@id']} : `, await result); return result; -} - +}; /** * Check if one resource match one filter @@ -191,7 +210,7 @@ const matchFilter = async ( fieldsAttr: string, searchForm: any, filterId: string, - throwOn: boolean + throwOn: boolean, ) => { let fields: string[] | null = null; @@ -202,9 +221,11 @@ const matchFilter = async ( fields = window.cachePropsSearchFilter[cacheKey].setFields; } else if (window.cachePropsSearchFilter[cacheKey].setSearchFields !== null) { fields = window.cachePropsSearchFilter[cacheKey].setSearchFields; - } else { // search on 1 field + } else { + // search on 1 field //FIXME: Better assumption that just using ldp:contains does the job ? - if (!(await resource[filter]) && filter.includes('ldp:contains')) { // nested field + if (!(await resource[filter]) && filter.includes('ldp:contains')) { + // nested field // console.log(`No ${filter} found for ${resource['@id']} and ${filter} is a nested field. Trying to traverse path.`); const path1: string[] = filter.split('.'); const targetedType = path1[path1.length - 1]; @@ -214,33 +235,40 @@ const matchFilter = async ( targetIds = await traversePath(resource, path1, targetedType); // console.log(`TargetIds : ${targetIds} found for ${await resource['name']} : ${resource['@id']}`); - if (!Array.isArray(targetIds) || targetIds.length === 0 && query.value !== '') { + if ( + !Array.isArray(targetIds) || + (targetIds.length === 0 && query.value !== '') + ) { // console.log(`No targetIds found for ${resource['@id']} returning false`); throw throwOn ? false : true; } // console.log(`Do we have a match for ${resource['@id']} ?`, match); - return await matchValue(targetIds, query, throwOn);; + return await matchValue(targetIds, query, throwOn); } return matchValue(resource[filter], query, throwOn); } // search on multiple fields try { - await Promise.all((fields || []).map(field => - matchFilter( - resource, - field, - query, - fieldsAttr, - searchForm, - filterId, - true // stop searching when 1 filter is true (= OR) - ) - )); - } catch (e) { return true; } + await Promise.all( + (fields || []).map(field => + matchFilter( + resource, + field, + query, + fieldsAttr, + searchForm, + filterId, + true, // stop searching when 1 filter is true (= OR) + ), + ), + ); + } catch (e) { + return true; + } throw false; -} +}; /** * Check if one resource match all the filters @@ -258,11 +286,12 @@ const matchFilters = async ( filterNames: string[], fields: string, searchForm: any, - filterId: string + filterId: string, ): Promise<boolean> => { // return true if all filters values are contained in the corresponding field of the resource try { - await Promise.all(filterNames.map(async (filter) => { + await Promise.all( + filterNames.map(async filter => { let match = await matchFilter( resource, filter, @@ -270,13 +299,16 @@ const matchFilters = async ( fields, searchForm, filterId, - false // stop searching when 1 filter is false (= AND) + false, // stop searching when 1 filter is false (= AND) ); return match; - })); - } catch (e) { return false; } + }), + ); + } catch (e) { + return false; + } return true; -} +}; /** * Check which resources match the filters @@ -290,25 +322,25 @@ const searchInResources = async ( resources: object[], filters: SearchQuery, fields: string, - searchForm: any + searchForm: any, ) => { // Optim: use cache to do these things only once const filterNames = Object.keys(filters); const filterId = uniqID(); window.cachePropsSearchFilter = {}; - return Promise.all(resources.map(async (resource) => { - let match = await matchFilters( - resource, - filters, - filterNames, - fields, - searchForm, - filterId - ); - return match; - })); -} - -export { - searchInResources + return Promise.all( + resources.map(async resource => { + let match = await matchFilters( + resource, + filters, + filterNames, + fields, + searchForm, + filterId, + ); + return match; + }), + ); }; + +export { searchInResources }; diff --git a/src/libs/helpers.ts b/src/libs/helpers.ts index 812aec8d..ce00eefe 100644 --- a/src/libs/helpers.ts +++ b/src/libs/helpers.ts @@ -1,4 +1,4 @@ -import Fuse from "fuse.js"; +import Fuse from 'fuse.js'; function uniqID(): string { return '_' + (Math.random() * Math.pow(36, 20)).toString(36).slice(0, 10); @@ -10,11 +10,16 @@ function stringToDom(html: string): DocumentFragment { return template.content; } -async function evalTemplateString(str: string, variables: {[key:string]:any} = {}) { +async function evalTemplateString( + str: string, + variables: { [key: string]: any } = {}, +) { const keys = Object.keys(variables); const values = keys.map(key => variables[key]); try { - const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor + const AsyncFunction = Object.getPrototypeOf( + async function () {}, + ).constructor; const func = AsyncFunction.call(null, ...keys, 'return `' + str + '`'); return await func(...values); } catch (e) { @@ -24,8 +29,8 @@ async function evalTemplateString(str: string, variables: {[key:string]:any} = { } function importCSS(...stylesheets: string[]) { - const linksElements: HTMLLinkElement[] = []; - for(let url of stylesheets) { + const linksElements: HTMLLinkElement[] = []; + for (let url of stylesheets) { url = relativeSource(url); let link = Array.from(document.head.querySelectorAll('link')).find( link => link.href === url, @@ -36,38 +41,38 @@ function importCSS(...stylesheets: string[]) { link.href = url; document.head.appendChild(link); linksElements.push(link); - }; + } return linksElements; } /** * @param id an uniq id to avoid import a style twice * @param importer a callback returning this `import()` promise * @returns the style element - * + * * typical use: * ```js - * importInlineCSS('bootstrap', () => import('./css/bootstrap.css?inline')) + * importInlineCSS('bootstrap', () => import('./css/bootstrap.css?inline')) * // adding '?inline' lets Vite convert css to js * ``` */ function importInlineCSS( id: string, - importer: string | (() => string | Promise<string | { default: string }>) + importer: string | (() => string | Promise<string | { default: string }>), ) { id = `sib-inline-css-${id}`; let style = document.head.querySelector<HTMLStyleElement>(`style#${id}`); if (style) return style; - style = document.createElement("style"); + style = document.createElement('style'); style.id = id; document.head.appendChild(style); (async () => { let textContent: string; - if (typeof importer === "string") textContent = importer; + if (typeof importer === 'string') textContent = importer; else { const imported = await importer(); - if (typeof imported === "string") textContent = imported; - else textContent = imported.default || ""; + if (typeof imported === 'string') textContent = imported; + else textContent = imported.default || ''; } style.textContent = textContent; })(); @@ -91,11 +96,11 @@ function importJS(...plugins: string[]): HTMLScriptElement[] { function relativeSource(source: string) { if (!source.match(/^\..?\//)) return new URL(source, document.baseURI).href; const e = new Error(); - if(!e.stack) return source; + if (!e.stack) return source; const f2 = e.stack.split('\n').filter(l => l.includes(':'))[2]; let line = f2.match(/[a-z]+:.*$/); if (!line) return source; - const calledFile = line[0].replace(/(\:[0-9]+){2}\)?$/,''); + const calledFile = line[0].replace(/(\:[0-9]+){2}\)?$/, ''); source = new URL(source, calledFile).href; return source; } @@ -108,12 +113,12 @@ function loadScript(source: string) { script.async = true; script.onload = () => setTimeout(resolve, 0); script.src = source; - if(head) head.appendChild(script); + if (head) head.appendChild(script); }); } function domIsReady(): Promise<void> { - return new Promise(function(resolve) { + return new Promise(function (resolve) { if (document.readyState === 'complete') { resolve(); } else { @@ -122,7 +127,11 @@ function domIsReady(): Promise<void> { }); } -function setDeepProperty(obj: {[index:string]:any}, path: string[], value: any) { +function setDeepProperty( + obj: { [index: string]: any }, + path: string[], + value: any, +) { const name = path.shift(); if (name) { if (!(name in obj)) obj[name] = {}; @@ -135,16 +144,19 @@ function parseFieldsString(fields: string): string[] { let fieldsArray: string[]; // remove all sets from fields - while(fields.indexOf('(') > 0){ + while (fields.indexOf('(') > 0) { let firstBracket = fields.indexOf('('); - let noset = fields.substring(firstBracket, findClosingBracketMatchIndex(fields, firstBracket)+1) - fields = fields.replace(noset, '') + let noset = fields.substring( + firstBracket, + findClosingBracketMatchIndex(fields, firstBracket) + 1, + ); + fields = fields.replace(noset, ''); } const re = /((^\s*|,)\s*)(("(\\"|[^"])*")|('(\\'|[^'])*')|[^,]*)/gm; // match , not inside quotes fieldsArray = fields.match(re) || []; // separate fields if (!fieldsArray) return []; - return fieldsArray.map(a => a.replace(/^[\s,]+/, '')) // remove commas and spaces + return fieldsArray.map(a => a.replace(/^[\s,]+/, '')); // remove commas and spaces } function findClosingBracketMatchIndex(str: string, pos: number) { @@ -152,12 +164,12 @@ function findClosingBracketMatchIndex(str: string, pos: number) { let depth = 1; for (let i = pos + 1; i < str.length; i++) { switch (str[i]) { - case '(': - depth++; - break; - case ')': - if (--depth == 0) return i; - break; + case '(': + depth++; + break; + case ')': + if (--depth == 0) return i; + break; } } return -1; @@ -167,7 +179,9 @@ function defineComponent(tagName: string, componentClass: typeof HTMLElement) { if (!customElements.get(tagName)) { customElements.define(tagName, componentClass); } else { - console.warn(`Warning: the component "${tagName}" has already been loaded in another version of sib-core.`) + console.warn( + `Warning: the component "${tagName}" has already been loaded in another version of sib-core.`, + ); } } @@ -181,8 +195,9 @@ function fuzzyCompare(subject: string, search: string) { const compare: { [k: string]: (subject: any, query: any) => boolean } = { string(subject: string, query: string) { - if(query === '') return true; - if(subject.toString().toLowerCase().includes(String(query).toLowerCase())) return true; + if (query === '') return true; + if (subject.toString().toLowerCase().includes(String(query).toLowerCase())) + return true; return fuzzyCompare(subject, query); }, boolean(subject: boolean, query: boolean) { @@ -203,46 +218,46 @@ const compare: { [k: string]: (subject: any, query: any) => boolean } = { }, resource(subject, query) { // dropdown default ' - ' option return an empty string - if(query === '') return true; + if (query === '') return true; if (!query['@id']) return false; - const ret = (subject['@id'] === query['@id']); + const ret = subject['@id'] === query['@id']; return ret; - } + }, }; function generalComparator(a, b, order = 'asc') { let comparison = 0; if (typeof a === 'boolean' && typeof b === 'boolean') { - comparison = (a === b) ? 0 : a ? 1 : -1; + comparison = a === b ? 0 : a ? 1 : -1; } else if (!isNaN(a) && !isNaN(b)) { - comparison = Number(a) - Number(b); + comparison = Number(a) - Number(b); } else if (Array.isArray(a) && Array.isArray(b)) { comparison = a.length - b.length; - } else if (!isNaN(Date.parse(a)) && !isNaN(Date.parse(b))) { - const dateA = new Date(a); - const dateB = new Date(a); - comparison = dateA.getTime() - dateB.getTime(); + } else if (!isNaN(Date.parse(a)) && !isNaN(Date.parse(b))) { + const dateA = new Date(a); + const dateB = new Date(a); + comparison = dateA.getTime() - dateB.getTime(); } else if (typeof a === 'object' && typeof b === 'object') { - const aKeys = Object.keys(a); - const bKeys = Object.keys(b); - comparison = aKeys.length - bKeys.length; + const aKeys = Object.keys(a); + const bKeys = Object.keys(b); + comparison = aKeys.length - bKeys.length; } else if (a == null || b == null) { - comparison = a == null ? (b == null ? 0 : -1) : (b == null ? 1 : 0); + comparison = a == null ? (b == null ? 0 : -1) : b == null ? 1 : 0; } else { - comparison = a.toString().localeCompare(b.toString()); + comparison = a.toString().localeCompare(b.toString()); } if (order === 'desc') { - comparison = comparison * -1; + comparison = comparison * -1; } return comparison; -}; - +} function transformArrayToContainer(resource: object) { const newValue = { ...resource }; - for (let predicate of Object.keys(newValue)) { // iterate over all properties + for (let predicate of Object.keys(newValue)) { + // iterate over all properties const predicateValue = newValue[predicate]; if (!predicateValue || typeof predicateValue !== 'object') continue; // undefined or literal, do nothing if (['permissions', '@context'].includes(predicate)) continue; // do not transform permissions and context @@ -252,47 +267,52 @@ function transformArrayToContainer(resource: object) { newValue[predicate] = transformArrayToContainer(resource[predicate]); } - if (Array.isArray(predicateValue) && predicateValue['@id']) { // Do not systematically transform arrays to containers + if (Array.isArray(predicateValue) && predicateValue['@id']) { + // Do not systematically transform arrays to containers newValue[predicate] = { '@id': predicateValue['@id'], - 'ldp:contains': [...predicateValue] + 'ldp:contains': [...predicateValue], }; - newValue[predicate]['ldp:contains'].forEach((childPredicate: any, index: number) => { // but check all nested resources - newValue[predicate]['ldp:contains'][index] = transformArrayToContainer(childPredicate); - }); + newValue[predicate]['ldp:contains'].forEach( + (childPredicate: any, index: number) => { + // but check all nested resources + newValue[predicate]['ldp:contains'][index] = + transformArrayToContainer(childPredicate); + }, + ); } } return newValue; } export default class AsyncIterableBuilder<Type> { - readonly #values: Promise<{ value: Type; done: boolean }>[] = [] - #resolve!: (value: { value: Type; done: boolean }) => void - readonly iterable: AsyncIterable<Type> - readonly next: (value: Type, done?: boolean) => void + readonly #values: Promise<{ value: Type; done: boolean }>[] = []; + #resolve!: (value: { value: Type; done: boolean }) => void; + readonly iterable: AsyncIterable<Type>; + readonly next: (value: Type, done?: boolean) => void; constructor() { - this.#nextPromise() - this.iterable = this.#createIterable() - this.next = this.#next.bind(this) + this.#nextPromise(); + this.iterable = this.#createIterable(); + this.next = this.#next.bind(this); } async *#createIterable() { for (let index = 0; ; index++) { - const { value, done } = await this.#values[index] - delete this.#values[index] - yield value - if (done) return + const { value, done } = await this.#values[index]; + delete this.#values[index]; + yield value; + if (done) return; } } #next(value: Type, done: boolean = false) { - this.#resolve({ value, done }) - this.#nextPromise() + this.#resolve({ value, done }); + this.#nextPromise(); } #nextPromise() { - this.#values.push(new Promise(resolve => (this.#resolve = resolve))) + this.#values.push(new Promise(resolve => (this.#resolve = resolve))); } } @@ -303,7 +323,7 @@ import { const asyncQuerySelector: AsyncQuerySelectorType = ( selector: string, - parent: ParentNode = document + parent: ParentNode = document, ) => new Promise<Element>(resolve => { const element = parent.querySelector(selector); @@ -323,7 +343,7 @@ const asyncQuerySelector: AsyncQuerySelectorType = ( const asyncQuerySelectorAll: AsyncQuerySelectorAllType = ( selector: string, - parent: ParentNode = document + parent: ParentNode = document, ) => { const delivered = new WeakSet<Element>(); const { next, iterable } = new AsyncIterableBuilder<Element>(); diff --git a/src/libs/interfaces.ts b/src/libs/interfaces.ts index 89a7a5a0..fed98505 100644 --- a/src/libs/interfaces.ts +++ b/src/libs/interfaces.ts @@ -1,11 +1,11 @@ -import { Profiler } from "../logger"; +import { Profiler } from '../logger'; export interface AccessorStaticInterface { [key: string]: { get: Function; set: Function; - } -}; + }; +} export interface ArrayOfHooksInterface { created: HookInterface[]; @@ -15,7 +15,7 @@ export interface ArrayOfHooksInterface { export interface AttributeChangedCallbackInterface { (newValue: any, oldValue: any): void; -}; +} export interface AttributeDefinitionInterface { type?: any; @@ -28,25 +28,29 @@ export interface AttributesDefinitionInterface { [key: string]: AttributeDefinitionInterface; } -export type ComponentConstructorInterface = new (element: HTMLElement) => ComponentInterface; +export type ComponentConstructorInterface = new ( + element: HTMLElement, +) => ComponentInterface; export interface ComponentInterface { profiler: Profiler; element: HTMLElement; - created():void; - attached():void; - detached():void; + created(): void; + attached(): void; + detached(): void; - attributesCallback(key: string, value: any, oldValue: any):void; + attributesCallback(key: string, value: any, oldValue: any): void; } -export interface ComponentStaticInterface extends HasAttributesDefinitionInterface, HasInitialStateInterface { +export interface ComponentStaticInterface + extends HasAttributesDefinitionInterface, + HasInitialStateInterface { name: String; hooks: ArrayOfHooksInterface; methods: Map<string, Function>; accessors: AccessorStaticInterface; -}; +} export interface HasAttributesDefinitionInterface { attributes?: AttributesDefinitionInterface | undefined; @@ -68,28 +72,32 @@ export interface HasMixinsInterface { export interface HookInterface { (): void; -}; +} -export interface MixinStaticInterface extends HasAttributesDefinitionInterface, HasMixinsInterface, HasInitialStateInterface, HasHooksInterface { +export interface MixinStaticInterface + extends HasAttributesDefinitionInterface, + HasMixinsInterface, + HasInitialStateInterface, + HasHooksInterface { name: String; -}; +} export interface LocationResourceInterface { lat?: HookInterface; lng?: HookInterface; } export interface Query { - value: any - type: "boolean" | "number" | "range" | "resource" | "string"; - list: boolean + value: any; + type: 'boolean' | 'number' | 'range' | 'resource' | 'string'; + list: boolean; } export interface SearchQuery { - [key: string]: Query + [key: string]: Query; } export interface FilterEventOptions { value: string; inputLabel: string; type: string; -} \ No newline at end of file +} diff --git a/src/libs/lit-helpers.ts b/src/libs/lit-helpers.ts index b5553d67..83d828b0 100644 --- a/src/libs/lit-helpers.ts +++ b/src/libs/lit-helpers.ts @@ -12,7 +12,7 @@ import { BooleanAttributePart, EventPart, PropertyPart, - ElementPart + ElementPart, } from 'lit'; import { directive, Directive, PartInfo, PartType } from 'lit/directive.js'; @@ -25,7 +25,6 @@ type SpreadPartType = | PropertyPart | ElementPart; - const prevCache = new WeakMap(); class SpreadDirective extends Directive { @@ -54,7 +53,9 @@ class SpreadDirective extends Directive { if (part.type === PartType.ATTRIBUTE || part.type === PartType.PROPERTY) { element = part.element; } else { - console.warn('Unsupported part type or missing element, skipping update.'); + console.warn( + 'Unsupported part type or missing element, skipping update.', + ); return noChange; } @@ -147,13 +148,22 @@ interface CachedTemplateStrings { needlessValues: CachedNeedlessValue[]; } -const templateStringsCache = new WeakMap<TemplateStringsArray, CachedTemplateStrings[]>(); +const templateStringsCache = new WeakMap< + TemplateStringsArray, + CachedTemplateStrings[] +>(); -function filterOutNeedlessValues(arr: any[], needlessValues: CachedNeedlessValue[]): any[] { +function filterOutNeedlessValues( + arr: any[], + needlessValues: CachedNeedlessValue[], +): any[] { return arr.filter((_, i) => !needlessValues.some(nv => nv.index === i)); } -export function preHTML(strings: TemplateStringsArray, ...values: any[]): TemplateResult { +export function preHTML( + strings: TemplateStringsArray, + ...values: any[] +): TemplateResult { let cachedStrings = templateStringsCache.get(strings); if (cachedStrings) { @@ -163,7 +173,10 @@ export function preHTML(strings: TemplateStringsArray, ...values: any[]): Templa if (isSame) { // Return cached template result if values match - return html(cached.strings, ...filterOutNeedlessValues(values, needlessValues)); + return html( + cached.strings, + ...filterOutNeedlessValues(values, needlessValues), + ); } } } @@ -196,5 +209,8 @@ export function preHTML(strings: TemplateStringsArray, ...values: any[]): Templa needlessValues, }); - return html(finalStrings as TemplateStringsArray, ...filterOutNeedlessValues(values, needlessValues)); -} \ No newline at end of file + return html( + finalStrings as TemplateStringsArray, + ...filterOutNeedlessValues(values, needlessValues), + ); +} diff --git a/src/libs/polyfills.ts b/src/libs/polyfills.ts index 6ad45348..ce7f696f 100644 --- a/src/libs/polyfills.ts +++ b/src/libs/polyfills.ts @@ -7,7 +7,7 @@ if (!('flat' in Array.prototype)) { if (depth === 0) return Array.prototype.slice.call(this); return Array.prototype.reduce.call<any, any[], any[]>( this, - function(acc:any[], cur: any) { + function (acc: any[], cur: any) { if (Array.isArray(cur)) { acc.push.apply(acc, flat.call(cur, depth - 1)); } else { @@ -24,7 +24,7 @@ if (!('flat' in Array.prototype)) { // Element.prototype.toggleAttribute if (!Element.prototype.toggleAttribute) { - Element.prototype.toggleAttribute = function(name, force = undefined) { + Element.prototype.toggleAttribute = function (name, force = undefined) { if (force !== undefined) force = !!force; if (this.hasAttribute(name)) { @@ -40,4 +40,4 @@ if (!Element.prototype.toggleAttribute) { }; } -export {} +export {}; diff --git a/src/libs/store/custom-getter.ts b/src/libs/store/custom-getter.ts index 15d74573..baca2655 100644 --- a/src/libs/store/custom-getter.ts +++ b/src/libs/store/custom-getter.ts @@ -4,313 +4,392 @@ import type { Resource } from '../../mixins/interfaces'; const ContextParser = JSONLDContextParser.ContextParser; - export class CustomGetter { - resource: any; // content of the requested resource - resourceId: string; - clientContext: object; // context given by the app - serverContext: object; // context given by the server - parentId: string; // id of the parent resource, used to get the absolute url of the current resource - containerTypes: string[]; // types of resources interpreted as containers - serverPagination: object; // pagination attributes to give to server - serverSearch: object; // search attributes to give to server - - constructor( - resourceId: string, - resource: object, - clientContext: object, - serverContext: object, - parentId: string = "", - serverPagination: object = {}, - serverSearch: object = {}) { - this.clientContext = clientContext; - this.serverContext = serverContext; - this.parentId = parentId; - this.resource = resource; - this.resourceId = resourceId; - this.serverPagination = serverPagination; - this.serverSearch = serverSearch; - - this.containerTypes = [ - this.getExpandedPredicate("ldp:Container"), - this.getExpandedPredicate("ldp:BasicContainer"), - this.getExpandedPredicate("ldp:DirectContainer"), - this.getExpandedPredicate("ldp:IndirectContainer"), - this.getExpandedPredicate("sib:federatedContainer"), - ]; - } - - /** - * Get the property of a resource for a given path - * Which means that if the resource is not complete, it will fetch it - * And that we handle the `.` notation, traversing the path recursively - * @param path: string - */ - async get(path: any) { - if (!path) return; - - // Specific case where the predicates is a full IRI, avoid splitting it on the dot notation - try { - let isUrl = new URL(path); - // My goal is to be able to solve user['circles.ldp:contains'] on the fly - // If we do not check the url protocol, then it is considered valid - if (!isUrl.protocol.startsWith('http')) throw new Error('Not a valid HTTP url'); - // If the path is a HTTP-scheme based URL, we need to fetch the resource directly - if (isUrl) { - let resources = this.resource[this.getExpandedPredicate(path)]; - if (!resources) return undefined; - if (!Array.isArray(resources)) resources = [resources]; // convert to array if compacted to 1 resource - - let result = resources ? resources.map((res: object) => { - let resource: any = store.get(res['@id']); - if (resource) return resource; - - // if not in cache, generate the basic resource - resource = new CustomGetter(res['@id'], { '@id': res['@id'] }, this.clientContext, this.serverContext, this.parentId).getProxy() - store.cacheResource(res['@id'], resource); // put it in cache - return resource; // and return it - }) : []; - - return result; - } - } catch (e) { - if (!path.split) return undefined; - - // Split the path on each dots - const path1: string[] = path.split('.'); - - // Intermediate path var to request each resource individually until the path traversal is completed - const path2: string[] = []; - - // Actual value found from the store, if any - let value: any; - - if (!this.isFullResource()) { // if resource is not complete, fetch it first - await this.getResource(this.resourceId, {...this.clientContext, ...this.serverContext}, this.parentId); - } - - // If the path contains dot, we need to traverse the path recursively - // We do that by poping one element from path1 at each step and affecting it to path2 - // Trying to get the value from it - while (true) { - value = await this.resource[this.getExpandedPredicate(path1[0])]; - - if (path1.length <= 1) break; // no dot path - const lastPath1El = path1.pop(); - if(lastPath1El) path2.unshift(lastPath1El); - } - - if (path2.length === 0) { // end of the path - if (!value || !value['@id']) return this.getLiteralValue(value); // no value or not a resource - return await this.getResource(value['@id'], {...this.clientContext, ...this.serverContext}, this.parentId || this.resourceId); // return complete resource - } - if (!value || !value['@id']) return undefined; - - let resource = await this.getResource(value['@id'], {...this.clientContext, ...this.serverContext}, this.parentId || this.resourceId); - store.subscribeResourceTo(this.resourceId, value['@id']); - return resource ? await resource[path2.join('.')] : undefined; // return value - } - } - - /** - * Return value depending of the current language - * @param value - * @returns - */ - getLiteralValue(value: any): string|string[]|null { - if (typeof value === "object") { // value object: https://www.w3.org/TR/json-ld11/#value-objects - if (value['@value']) { // 1 language - return value['@value']; - } else if (Array.isArray(value)) { - if (value.length === 0) return null; - if(Array.isArray(value[0])) { // multiple languages - const ln = store._getLanguage(); - let translatedValue = value.find(v => v['@language'] && v['@language'] === ln); // find current language - if (!translatedValue) translatedValue = value.find(v => v['@language'] && v['@language'] === 'en'); // default to en - return translatedValue ? (translatedValue['@value'] || null) : null; // return value when no translated value is found - } - return value; - } - } - return value; // simple value - } - - - /** - * Cache resource in the store, and return the created proxy - * @param id - * @param context - * @param iriParent - */ - async getResource(id: string, context: object, iriParent: string, forceFetch: boolean = false): Promise<Resource | null> { - if (id.startsWith('_:b')) return store.get(id + iriParent); // anonymous node = get from cache - return store.getData(id, context, iriParent, undefined ,forceFetch); - } - - - /** - * Return true if the resource is a container - */ - isContainer(): boolean { - if (this.resource["@type"]) { // @type is an array - if (Array.isArray(this.resource["@type"])) - return this.containerTypes.some(type => this.resource["@type"].includes(type)); - return this.containerTypes.includes(this.resource["@type"]); - } else if (this.resource["type"]) { - if (Array.isArray(this.resource["type"])) - return this.containerTypes.some(type => this.resource["type"].includes(type)); - return this.containerTypes.includes(this.resource["type"]); - } - - return false; - } - - /** - * Return true if the given key in the current resource in an array - */ - isArray(): boolean { - if (Array.isArray(this.resource)) - return true; - - return false; - } - - - /** - * Get all properties of a resource - */ - getProperties(): string[] { - return Object.keys(this.resource).map(prop => this.getCompactedPredicate(prop)); - } - - /** - * Get children of container as objects - */ - getChildren(predicateName : string): object[] { - return this.resource[this.getExpandedPredicate(predicateName)] || []; - } - - /** - * Get children of container as Proxys - */ - getLdpContains(): CustomGetter[]|null { - let children = this.resource[this.getExpandedPredicate("ldp:contains")]; - if (!children) return null; - if (!Array.isArray(children)) children = [children]; // convert to array if compacted to 1 resource - - let result = children ? children.map((res: object) => { - let resource: any = store.get(res['@id']); - if (resource) return resource; - - // if not in cache, generate the basic resource - resource = new CustomGetter(res['@id'], { '@id': res['@id'] }, this.clientContext, this.serverContext, this.parentId).getProxy() - store.cacheResource(res['@id'], resource); // put it in cache - return resource; // and return it - }) : []; + resource: any; // content of the requested resource + resourceId: string; + clientContext: object; // context given by the app + serverContext: object; // context given by the server + parentId: string; // id of the parent resource, used to get the absolute url of the current resource + containerTypes: string[]; // types of resources interpreted as containers + serverPagination: object; // pagination attributes to give to server + serverSearch: object; // search attributes to give to server + + constructor( + resourceId: string, + resource: object, + clientContext: object, + serverContext: object, + parentId: string = '', + serverPagination: object = {}, + serverSearch: object = {}, + ) { + this.clientContext = clientContext; + this.serverContext = serverContext; + this.parentId = parentId; + this.resource = resource; + this.resourceId = resourceId; + this.serverPagination = serverPagination; + this.serverSearch = serverSearch; + + this.containerTypes = [ + this.getExpandedPredicate('ldp:Container'), + this.getExpandedPredicate('ldp:BasicContainer'), + this.getExpandedPredicate('ldp:DirectContainer'), + this.getExpandedPredicate('ldp:IndirectContainer'), + this.getExpandedPredicate('sib:federatedContainer'), + ]; + } + + /** + * Get the property of a resource for a given path + * Which means that if the resource is not complete, it will fetch it + * And that we handle the `.` notation, traversing the path recursively + * @param path: string + */ + async get(path: any) { + if (!path) return; + + // Specific case where the predicates is a full IRI, avoid splitting it on the dot notation + try { + let isUrl = new URL(path); + // My goal is to be able to solve user['circles.ldp:contains'] on the fly + // If we do not check the url protocol, then it is considered valid + if (!isUrl.protocol.startsWith('http')) + throw new Error('Not a valid HTTP url'); + // If the path is a HTTP-scheme based URL, we need to fetch the resource directly + if (isUrl) { + let resources = this.resource[this.getExpandedPredicate(path)]; + if (!resources) return undefined; + if (!Array.isArray(resources)) resources = [resources]; // convert to array if compacted to 1 resource + + let result = resources + ? resources.map((res: object) => { + let resource: any = store.get(res['@id']); + if (resource) return resource; + + // if not in cache, generate the basic resource + resource = new CustomGetter( + res['@id'], + { '@id': res['@id'] }, + this.clientContext, + this.serverContext, + this.parentId, + ).getProxy(); + store.cacheResource(res['@id'], resource); // put it in cache + return resource; // and return it + }) + : []; return result; + } + } catch (e) { + if (!path.split) return undefined; + + // Split the path on each dots + const path1: string[] = path.split('.'); + + // Intermediate path var to request each resource individually until the path traversal is completed + const path2: string[] = []; + + // Actual value found from the store, if any + let value: any; + + if (!this.isFullResource()) { + // if resource is not complete, fetch it first + await this.getResource( + this.resourceId, + { ...this.clientContext, ...this.serverContext }, + this.parentId, + ); + } + + // If the path contains dot, we need to traverse the path recursively + // We do that by poping one element from path1 at each step and affecting it to path2 + // Trying to get the value from it + while (true) { + value = await this.resource[this.getExpandedPredicate(path1[0])]; + + if (path1.length <= 1) break; // no dot path + const lastPath1El = path1.pop(); + if (lastPath1El) path2.unshift(lastPath1El); + } + + if (path2.length === 0) { + // end of the path + if (!value || !value['@id']) return this.getLiteralValue(value); // no value or not a resource + return await this.getResource( + value['@id'], + { ...this.clientContext, ...this.serverContext }, + this.parentId || this.resourceId, + ); // return complete resource + } + if (!value || !value['@id']) return undefined; + + let resource = await this.getResource( + value['@id'], + { ...this.clientContext, ...this.serverContext }, + this.parentId || this.resourceId, + ); + store.subscribeResourceTo(this.resourceId, value['@id']); + return resource ? await resource[path2.join('.')] : undefined; // return value } - - - merge(resource: CustomGetter) { - this.resource = { ...this.getResourceData(), ...resource.getResourceData() } - } - - getResourceData(): object { return this.resource } - - /** - * return true resource seems complete - * @param prop - */ - isFullResource(): boolean { - let propertiesKeys = Object.keys(this.resource).filter(p => !p.startsWith('@')); - if (this.resource['@id'].startsWith('_:b')) return true; // anonymous node = considered as always full - - if (propertiesKeys.length === 1 && propertiesKeys[0] === this.getExpandedPredicate('permissions')) - return false; // If only the permissions are present, then the resource is not complete - else if (propertiesKeys.length > 0) return true; - - return false; - } - - /** - * Get permissions of a resource - * @param resourceId - * @returns - */ - async getPermissions(): Promise<string[]> { - let permissions = this.resource[this.getExpandedPredicate("permissions")]; - if (!permissions) { // if no permission, re-fetch data from store - await this.getResource( - this.resourceId, - { ...this.clientContext, ...this.serverContext }, - this.parentId, - true - ); - permissions = this.resource[this.getExpandedPredicate("permissions")]; + } + + /** + * Return value depending of the current language + * @param value + * @returns + */ + getLiteralValue(value: any): string | string[] | null { + if (typeof value === 'object') { + // value object: https://www.w3.org/TR/json-ld11/#value-objects + if (value['@value']) { + // 1 language + return value['@value']; + } else if (Array.isArray(value)) { + if (value.length === 0) return null; + if (Array.isArray(value[0])) { + // multiple languages + const ln = store._getLanguage(); + let translatedValue = value.find( + v => v['@language'] && v['@language'] === ln, + ); // find current language + if (!translatedValue) + translatedValue = value.find( + v => v['@language'] && v['@language'] === 'en', + ); // default to en + return translatedValue ? translatedValue['@value'] || null : null; // return value when no translated value is found } - - if (!Array.isArray(permissions)) permissions = [permissions]; // convert to array if compacted to 1 resource - - return permissions ? permissions : []; + return value; + } } - - /** - * returns compacted @type of resource - */ - getType(): string { - return this.resource['@type'] ? this.getCompactedIri(this.resource['@type']) : ''; - } - - /** - * Remove the resource from the cache - */ - clearCache(): void { - store.clearCache(this.resourceId); + return value; // simple value + } + + /** + * Cache resource in the store, and return the created proxy + * @param id + * @param context + * @param iriParent + */ + async getResource( + id: string, + context: object, + iriParent: string, + forceFetch: boolean = false, + ): Promise<Resource | null> { + if (id.startsWith('_:b')) return store.get(id + iriParent); // anonymous node = get from cache + return store.getData(id, context, iriParent, undefined, forceFetch); + } + + /** + * Return true if the resource is a container + */ + isContainer(): boolean { + if (this.resource['@type']) { + // @type is an array + if (Array.isArray(this.resource['@type'])) + return this.containerTypes.some(type => + this.resource['@type'].includes(type), + ); + return this.containerTypes.includes(this.resource['@type']); + } else if (this.resource['type']) { + if (Array.isArray(this.resource['type'])) + return this.containerTypes.some(type => + this.resource['type'].includes(type), + ); + return this.containerTypes.includes(this.resource['type']); } - getExpandedPredicate(property: string) { return ContextParser.expandTerm(property, { ...this.clientContext, ...this.serverContext }, true) } - getCompactedPredicate(property: string) { return ContextParser.compactIri(property, { ...this.clientContext, ...this.serverContext }, true) } - getCompactedIri(id: string) { return ContextParser.compactIri(id, { ...this.clientContext, ...this.serverContext }) } - toString() { return this.getCompactedIri(this.resource['@id']) } - [Symbol.toPrimitive]() { return this.getCompactedIri(this.resource['@id']) } - - - /** - * Returns a Proxy which handles the different get requests - */ - getProxy() { - return new Proxy(this, { - get: (resource, property) => { - if (!this.resource) return undefined; - if (typeof resource[property] === 'function') return resource[property].bind(resource); - - switch (property) { - case '@id': - if (this.resource['@id']) - return this.getCompactedIri(this.resource['@id']); // Compact @id if possible - else - console.log(this.resource, this.resource['@id']); - return; - case '@type': - return this.resource['@type']; // return synchronously - case 'properties': - return this.getProperties(); - case 'ldp:contains': - return this.getLdpContains(); // returns standard arrays synchronously - case 'permissions': - return this.getPermissions(); // get expanded permissions - case 'clientContext': - return this.clientContext; // get saved client context to re-fetch easily a resource - case 'serverContext': - return this.serverContext; // get saved client context to re-fetch easily a resource - case 'then': - return; - default: - // FIXME: missing 'await' - return resource.get(property) - } - } + return false; + } + + /** + * Return true if the given key in the current resource in an array + */ + isArray(): boolean { + if (Array.isArray(this.resource)) return true; + + return false; + } + + /** + * Get all properties of a resource + */ + getProperties(): string[] { + return Object.keys(this.resource).map(prop => + this.getCompactedPredicate(prop), + ); + } + + /** + * Get children of container as objects + */ + getChildren(predicateName: string): object[] { + return this.resource[this.getExpandedPredicate(predicateName)] || []; + } + + /** + * Get children of container as Proxys + */ + getLdpContains(): CustomGetter[] | null { + let children = this.resource[this.getExpandedPredicate('ldp:contains')]; + if (!children) return null; + if (!Array.isArray(children)) children = [children]; // convert to array if compacted to 1 resource + + let result = children + ? children.map((res: object) => { + let resource: any = store.get(res['@id']); + if (resource) return resource; + + // if not in cache, generate the basic resource + resource = new CustomGetter( + res['@id'], + { '@id': res['@id'] }, + this.clientContext, + this.serverContext, + this.parentId, + ).getProxy(); + store.cacheResource(res['@id'], resource); // put it in cache + return resource; // and return it }) + : []; + + return result; + } + + merge(resource: CustomGetter) { + this.resource = { + ...this.getResourceData(), + ...resource.getResourceData(), + }; + } + + getResourceData(): object { + return this.resource; + } + + /** + * return true resource seems complete + * @param prop + */ + isFullResource(): boolean { + let propertiesKeys = Object.keys(this.resource).filter( + p => !p.startsWith('@'), + ); + if (this.resource['@id'].startsWith('_:b')) return true; // anonymous node = considered as always full + + if ( + propertiesKeys.length === 1 && + propertiesKeys[0] === this.getExpandedPredicate('permissions') + ) + return false; // If only the permissions are present, then the resource is not complete + else if (propertiesKeys.length > 0) return true; + + return false; + } + + /** + * Get permissions of a resource + * @param resourceId + * @returns + */ + async getPermissions(): Promise<string[]> { + let permissions = this.resource[this.getExpandedPredicate('permissions')]; + if (!permissions) { + // if no permission, re-fetch data from store + await this.getResource( + this.resourceId, + { ...this.clientContext, ...this.serverContext }, + this.parentId, + true, + ); + permissions = this.resource[this.getExpandedPredicate('permissions')]; } -} \ No newline at end of file + + if (!Array.isArray(permissions)) permissions = [permissions]; // convert to array if compacted to 1 resource + + return permissions ? permissions : []; + } + + /** + * returns compacted @type of resource + */ + getType(): string { + return this.resource['@type'] + ? this.getCompactedIri(this.resource['@type']) + : ''; + } + + /** + * Remove the resource from the cache + */ + clearCache(): void { + store.clearCache(this.resourceId); + } + + getExpandedPredicate(property: string) { + return ContextParser.expandTerm( + property, + { ...this.clientContext, ...this.serverContext }, + true, + ); + } + getCompactedPredicate(property: string) { + return ContextParser.compactIri( + property, + { ...this.clientContext, ...this.serverContext }, + true, + ); + } + getCompactedIri(id: string) { + return ContextParser.compactIri(id, { + ...this.clientContext, + ...this.serverContext, + }); + } + toString() { + return this.getCompactedIri(this.resource['@id']); + } + [Symbol.toPrimitive]() { + return this.getCompactedIri(this.resource['@id']); + } + + /** + * Returns a Proxy which handles the different get requests + */ + getProxy() { + return new Proxy(this, { + get: (resource, property) => { + if (!this.resource) return undefined; + if (typeof resource[property] === 'function') + return resource[property].bind(resource); + + switch (property) { + case '@id': + if (this.resource['@id']) + return this.getCompactedIri(this.resource['@id']); // Compact @id if possible + else console.log(this.resource, this.resource['@id']); + return; + case '@type': + return this.resource['@type']; // return synchronously + case 'properties': + return this.getProperties(); + case 'ldp:contains': + return this.getLdpContains(); // returns standard arrays synchronously + case 'permissions': + return this.getPermissions(); // get expanded permissions + case 'clientContext': + return this.clientContext; // get saved client context to re-fetch easily a resource + case 'serverContext': + return this.serverContext; // get saved client context to re-fetch easily a resource + case 'then': + return; + default: + // FIXME: missing 'await' + return resource.get(property); + } + }, + }); + } +} diff --git a/src/libs/store/server-pagination.ts b/src/libs/store/server-pagination.ts index 4edcc9d8..3222a343 100644 --- a/src/libs/store/server-pagination.ts +++ b/src/libs/store/server-pagination.ts @@ -1,24 +1,29 @@ export interface ServerPaginationOptions { - offset: number; - limit: number; + offset: number; + limit: number; } export function formatAttributesToServerPaginationOptions( - elementAttributes: { name: string, value: number }[] + elementAttributes: { name: string; value: number }[], ): ServerPaginationOptions | undefined { - const attributes = new Map(Array.from(elementAttributes).map(({ name, value }) => [name, value])) - const limit = attributes.get('limit'); - const offset = attributes.get('offset'); - if (!offset || !limit) return; - return { - limit: limit, - offset: offset, - } + const attributes = new Map( + Array.from(elementAttributes).map(({ name, value }) => [name, value]), + ); + const limit = attributes.get('limit'); + const offset = attributes.get('offset'); + if (!offset || !limit) return; + return { + limit: limit, + offset: offset, + }; } -export function appendServerPaginationToIri(iri: string, options: ServerPaginationOptions): string { - const first = iri.includes('?') ? '&' : '?'; - const limit = options.limit; - const offset = options.offset; - return `${iri}${first}limit=${limit}&offset=${offset}`; -} \ No newline at end of file +export function appendServerPaginationToIri( + iri: string, + options: ServerPaginationOptions, +): string { + const first = iri.includes('?') ? '&' : '?'; + const limit = options.limit; + const offset = options.offset; + return `${iri}${first}limit=${limit}&offset=${offset}`; +} diff --git a/src/libs/store/server-search.ts b/src/libs/store/server-search.ts index 2ca9e85b..51b79756 100644 --- a/src/libs/store/server-search.ts +++ b/src/libs/store/server-search.ts @@ -5,22 +5,27 @@ export interface ServerSearchOptions { } export function formatAttributesToServerSearchOptions( - elementAttributes: Iterable<Attr> + elementAttributes: Iterable<Attr>, ): Partial<ServerSearchOptions> { - const attributes = new Map(Array.from(elementAttributes).map(({ name, value }) => [name, value])); - const fields = attributes.get('server-search-fields')?.split(",").map((field) => field.trim()); + const attributes = new Map( + Array.from(elementAttributes).map(({ name, value }) => [name, value]), + ); + const fields = attributes + .get('server-search-fields') + ?.split(',') + .map(field => field.trim()); const value = attributes.get('server-search-value')?.trim(); const method = attributes.get('server-search-method')?.trim(); return { fields: fields && fields.length > 0 ? fields : undefined, value: value ? value : undefined, - method: method ? method : undefined - } + method: method ? method : undefined, + }; } export function mergeServerSearchOptions( attributesOptions?: Partial<ServerSearchOptions>, - dynamicOptions?: Partial<ServerSearchOptions> + dynamicOptions?: Partial<ServerSearchOptions>, ): ServerSearchOptions | undefined { const fields = attributesOptions?.fields ?? dynamicOptions?.fields; const value = dynamicOptions?.value ?? attributesOptions?.value; @@ -29,10 +34,13 @@ export function mergeServerSearchOptions( return { fields, value, method }; } -export function appendServerSearchToIri(iri: string, options: ServerSearchOptions): string { +export function appendServerSearchToIri( + iri: string, + options: ServerSearchOptions, +): string { const first = iri.includes('?') ? '&' : '?'; const fields = options.fields.map(encodeURIComponent).join(','); const value = encodeURIComponent(options.value); const method = encodeURIComponent(options.method ?? 'ibasic'); return `${iri}${first}search-fields=${fields}&search-terms=${value}&search-method=${method}`; -} \ No newline at end of file +} diff --git a/src/libs/store/store.ts b/src/libs/store/store.ts index c632f850..16ac1fc0 100644 --- a/src/libs/store/store.ts +++ b/src/libs/store/store.ts @@ -16,29 +16,29 @@ const ContextParser = JSONLDContextParser.ContextParser; const myParser = new ContextParser(); export const base_context = { - '@vocab': "https://cdn.startinblox.com/owl#", - foaf: "http://xmlns.com/foaf/0.1/", - doap: "http://usefulinc.com/ns/doap#", - ldp: "http://www.w3.org/ns/ldp#", - rdfs: "http://www.w3.org/2000/01/rdf-schema#", - rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#", - xsd: "http://www.w3.org/2001/XMLSchema#", - geo: "http://www.w3.org/2003/01/geo/wgs84_pos#", - acl: "http://www.w3.org/ns/auth/acl#", - hd: "http://cdn.startinblox.com/owl/ttl/vocab.ttl#", - sib: "http://cdn.startinblox.com/owl/ttl/vocab.ttl#", - name: "rdfs:label", - deadline: "xsd:dateTime", - lat: "geo:lat", - lng: "geo:long", - jabberID: "foaf:jabberID", - permissions: "acl:accessControl", - mode: "acl:mode", - view: "acl:Read", - change: "acl:Write", - add: "acl:Append", - delete: "acl:Delete", - control: "acl:Control" + '@vocab': 'https://cdn.startinblox.com/owl#', + foaf: 'http://xmlns.com/foaf/0.1/', + doap: 'http://usefulinc.com/ns/doap#', + ldp: 'http://www.w3.org/ns/ldp#', + rdfs: 'http://www.w3.org/2000/01/rdf-schema#', + rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', + xsd: 'http://www.w3.org/2001/XMLSchema#', + geo: 'http://www.w3.org/2003/01/geo/wgs84_pos#', + acl: 'http://www.w3.org/ns/auth/acl#', + hd: 'http://cdn.startinblox.com/owl/ttl/vocab.ttl#', + sib: 'http://cdn.startinblox.com/owl/ttl/vocab.ttl#', + name: 'rdfs:label', + deadline: 'xsd:dateTime', + lat: 'geo:lat', + lng: 'geo:long', + jabberID: 'foaf:jabberID', + permissions: 'acl:accessControl', + mode: 'acl:mode', + view: 'acl:Read', + change: 'acl:Write', + add: 'acl:Append', + delete: 'acl:Delete', + control: 'acl:Control', }; class Store { @@ -55,7 +55,11 @@ class Store { this.subscriptionIndex = new Map(); this.subscriptionVirtualContainersIndex = new Map(); this.loadingList = new Set(); - this.headers = {'Accept': 'application/ld+json', 'Content-Type': 'application/ld+json', 'Cache-Control': 'must-revalidate'}; + this.headers = { + Accept: 'application/ld+json', + 'Content-Type': 'application/ld+json', + 'Cache-Control': 'must-revalidate', + }; this.fetch = this.storeOptions.fetchMethod; this.session = this.storeOptions.session; } @@ -70,7 +74,7 @@ class Store { * @param serverPagination - Server pagination options * @param serverSearch - Server search options * @param predicateName - predicate name if we target a specific predicate from the resource, useful for arrays - * + * * @returns The fetched resource * * @async @@ -78,28 +82,36 @@ class Store { async getData( id: string, context: any = {}, - parentId = "", + parentId = '', localData?: object, forceFetch: boolean = false, serverPagination?: ServerPaginationOptions, - serverSearch?: ServerSearchOptions - ): Promise<Resource|null> { + serverSearch?: ServerSearchOptions, + ): Promise<Resource | null> { let key = id; if (serverPagination) { - key = appendServerPaginationToIri(key, serverPagination) + key = appendServerPaginationToIri(key, serverPagination); } if (serverSearch) { - key = appendServerSearchToIri(key, serverSearch) + key = appendServerSearchToIri(key, serverSearch); } - if (localData == null && this.cache.has(key) && !this.loadingList.has(key)) { + if ( + localData == null && + this.cache.has(key) && + !this.loadingList.has(key) + ) { const resource = this.get(key); - if (resource && resource.isFullResource?.() && !forceFetch) return resource; // if resource is not complete, re-fetch it + if (resource && resource.isFullResource?.() && !forceFetch) + return resource; // if resource is not complete, re-fetch it } - return new Promise(async (resolve) => { - document.addEventListener('resourceReady', this.resolveResource(key, resolve)); + return new Promise(async resolve => { + document.addEventListener( + 'resourceReady', + this.resolveResource(key, resolve), + ); if (this.loadingList.has(key)) return; this.loadingList.add(key); @@ -107,25 +119,57 @@ class Store { // Generate proxy const clientContext = await myParser.parse(context); let resource: any = null; - if(this._isLocalId(id)) { - if(localData == null) localData = {}; - localData["@id"] = id; + if (this._isLocalId(id)) { + if (localData == null) localData = {}; + localData['@id'] = id; resource = localData; - } else try { - resource = localData || await this.fetchData(id, clientContext, parentId, serverPagination, serverSearch); - } catch (error) { console.error(error) } + } else + try { + resource = + localData || + (await this.fetchData( + id, + clientContext, + parentId, + serverPagination, + serverSearch, + )); + } catch (error) { + console.error(error); + } if (!resource) { this.loadingList.delete(key); - document.dispatchEvent(new CustomEvent('resourceReady', { detail: { id: key, resource: null, fetchedResource: null } })); + document.dispatchEvent( + new CustomEvent('resourceReady', { + detail: { id: key, resource: null, fetchedResource: null }, + }), + ); return; } - const serverContext = await myParser.parse([resource['@context'] || base_context]); + const serverContext = await myParser.parse([ + resource['@context'] || base_context, + ]); // const resourceProxy = new CustomGetter(key, resource, clientContext, serverContext, parentId ? parentId : key, serverPagination, serverSearch).getProxy(); // Cache proxy - await this.cacheGraph(resource, clientContext, serverContext, parentId ? parentId : key, serverPagination, serverSearch); + await this.cacheGraph( + resource, + clientContext, + serverContext, + parentId ? parentId : key, + serverPagination, + serverSearch, + ); this.loadingList.delete(key); - document.dispatchEvent(new CustomEvent('resourceReady', { detail: { id: key, resource: this.get(key), fetchedResource: resource } })); + document.dispatchEvent( + new CustomEvent('resourceReady', { + detail: { + id: key, + resource: this.get(key), + fetchedResource: resource, + }, + }), + ); }); } @@ -133,11 +177,14 @@ class Store { let authenticated = false; if (this.session) authenticated = await this.session; - if (this.fetch && authenticated) { // authenticated - return this.fetch.then(fn => fn(iri, options)) - } else { // anonymous - if (options.headers) options.headers = this._convertHeaders(options.headers); - return fetch(iri, options).then(function(response) { + if (this.fetch && authenticated) { + // authenticated + return this.fetch.then(fn => fn(iri, options)); + } else { + // anonymous + if (options.headers) + options.headers = this._convertHeaders(options.headers); + return fetch(iri, options).then(function (response) { return response; }); } @@ -155,21 +202,21 @@ class Store { async fetchData( id: string, context = {}, - parentId = "", + parentId = '', serverPagination?: ServerPaginationOptions, - serverSearch?: ServerSearchOptions + serverSearch?: ServerSearchOptions, ) { let iri = this._getAbsoluteIri(id, context, parentId); - if (serverPagination) iri = appendServerPaginationToIri(iri, serverPagination); + if (serverPagination) + iri = appendServerPaginationToIri(iri, serverPagination); if (serverSearch) iri = appendServerSearchToIri(iri, serverSearch); const headers = { ...this.headers, - 'accept-language': this._getLanguage() + 'accept-language': this._getLanguage(), // 'Prefer' : 'return=representation; max-triple-count="100"' // Commenting out for now as it raises CORS errors }; - /** * Fetch data with authentication if available (sib-auth) * @param iri - iri to call @@ -179,14 +226,14 @@ class Store { return this.fetchAuthn(iri, { method: 'GET', headers: headers, - credentials: 'include' - }).then((response) => { + credentials: 'include', + }).then(response => { if (!response.ok) return; return response.json(); - }) + }); } - /** + /** * Cache the whole graph * @param resource - graph fetched * @param clientContext - context of the client app @@ -201,7 +248,7 @@ class Store { parentContext: object, parentId: string, serverPagination?: ServerPaginationOptions, - serverSearch?: ServerSearchOptions + serverSearch?: ServerSearchOptions, ) { // Flatten and compact the graph, which is an issue with large containers having child permissions serialized // Because @@ -212,7 +259,9 @@ class Store { // Either we modify it by adding the parentId and we end up with // a lot of cached permissions objects associated with the container top resource (like xxxxx/circles/) const flattenedResources = await jsonld.flatten(resource); - const compactedResources: any[] = await Promise.all(flattenedResources.map(r => jsonld.compact(r, {}))) + const compactedResources: any[] = await Promise.all( + flattenedResources.map(r => jsonld.compact(r, {})), + ); for (let resource of compactedResources) { let id = resource['@id'] || resource['id']; let key = resource['@id'] || resource['id']; @@ -225,17 +274,34 @@ class Store { // Using a dedicated method in the custom-getter. // We have to add the server search and pagination attributes again here to the resource cache key - if (key === id && resource['@type'] == this.getExpandedPredicate("ldp:Container", clientContext)) { // Add only pagination and search params to the original resource - if (serverPagination) key = appendServerPaginationToIri(key, serverPagination); + if ( + key === id && + resource['@type'] == + this.getExpandedPredicate('ldp:Container', clientContext) + ) { + // Add only pagination and search params to the original resource + if (serverPagination) + key = appendServerPaginationToIri(key, serverPagination); if (serverSearch) key = appendServerSearchToIri(key, serverSearch); } - const resourceProxy = new CustomGetter(key, resource, clientContext, parentContext, parentId, serverPagination, serverSearch).getProxy(); - if (resourceProxy.isContainer()) this.subscribeChildren(resourceProxy, id); - - if (this.get(key)) { // if already cached, merge data + const resourceProxy = new CustomGetter( + key, + resource, + clientContext, + parentContext, + parentId, + serverPagination, + serverSearch, + ).getProxy(); + if (resourceProxy.isContainer()) + this.subscribeChildren(resourceProxy, id); + + if (this.get(key)) { + // if already cached, merge data this.cache.get(key).merge(resourceProxy); - } else { // else, put in cache + } else { + // else, put in cache this.cacheResource(key, resourceProxy); } } @@ -263,14 +329,16 @@ class Store { method: method, headers: this.headers, body: JSON.stringify(resource), - credentials: 'include' + credentials: 'include', }); const resourceProxy = store.get(id); - const clientContext = resourceProxy ? {...resourceProxy.clientContext, ...resource['@context']} : resource['@context'] + const clientContext = resourceProxy + ? { ...resourceProxy.clientContext, ...resource['@context'] } + : resource['@context']; this.clearCache(id); await this.getData(id, clientContext, '', resource); - return {ok: true} + return { ok: true }; } /** @@ -283,7 +351,7 @@ class Store { this.subscribeResourceTo(containerId, res['@id'] || res['id']); } } - + /** * Update a resource * @param method - can be POST, PUT or PATCH @@ -292,22 +360,35 @@ class Store { * @returns void */ async _updateResource(method: string, resource: object, id: string) { - if (!['POST', 'PUT', 'PATCH', '_LOCAL'].includes(method)) throw new Error('Error: method not allowed'); + if (!['POST', 'PUT', 'PATCH', '_LOCAL'].includes(method)) + throw new Error('Error: method not allowed'); const context = await myParser.parse([resource['@context'] || {}]); // parse context before expandTerm const expandedId = this._getExpandedId(id, context); - return this._fetch(method, resource, id).then(async(response) => { + return this._fetch(method, resource, id).then(async response => { if (response.ok) { - if(method !== '_LOCAL') { + if (method !== '_LOCAL') { this.clearCache(expandedId); } // clear cache - this.getData(expandedId, resource['@context']).then(async () => { // re-fetch data + this.getData(expandedId, resource['@context']).then(async () => { + // re-fetch data const nestedResources = await this.getNestedResources(resource, id); - const resourcesToRefresh = this.subscriptionVirtualContainersIndex.get(expandedId) || []; - const resourcesToNotify = this.subscriptionIndex.get(expandedId) || []; - - return this.refreshResources([...nestedResources, ...resourcesToRefresh]) // refresh related resources - .then(resourceIds => this.notifyResources([expandedId, ...resourceIds, ...resourcesToNotify])); // notify components + const resourcesToRefresh = + this.subscriptionVirtualContainersIndex.get(expandedId) || []; + const resourcesToNotify = + this.subscriptionIndex.get(expandedId) || []; + + return this.refreshResources([ + ...nestedResources, + ...resourcesToRefresh, + ]) // refresh related resources + .then(resourceIds => + this.notifyResources([ + expandedId, + ...resourceIds, + ...resourcesToNotify, + ]), + ); // notify components }); return response.headers?.get('Location') || null; } else { @@ -323,11 +404,18 @@ class Store { */ async refreshResources(resourceIds: string[]) { resourceIds = [...new Set(resourceIds.filter(id => this.cache.has(id)))]; // remove duplicates and not cached resources - const resourceWithContexts = resourceIds.map(resourceId => ({ "id": resourceId, "context": store.get(resourceId)?.clientContext })); + const resourceWithContexts = resourceIds.map(resourceId => ({ + id: resourceId, + context: store.get(resourceId)?.clientContext, + })); for (const resource of resourceWithContexts) { if (!this._isLocalId(resource.id)) this.clearCache(resource.id); } - await Promise.all(resourceWithContexts.map(({ id, context }) => this.getData(id, context || base_context))) + await Promise.all( + resourceWithContexts.map(({ id, context }) => + this.getData(id, context || base_context), + ), + ); return resourceIds; } /** @@ -347,13 +435,15 @@ class Store { async getNestedResources(resource: object, id: string) { const cachedResource = store.get(id); if (!cachedResource || cachedResource.isContainer?.()) return []; - let nestedProperties:any[] = []; + let nestedProperties: any[] = []; const excludeKeys = ['@context']; for (let p of Object.keys(resource)) { - if (resource[p] - && typeof resource[p] === 'object' - && !excludeKeys.includes(p) - && resource[p]['@id']) { + if ( + resource[p] && + typeof resource[p] === 'object' && + !excludeKeys.includes(p) && + resource[p]['@id'] + ) { nestedProperties.push(resource[p]['@id']); } } @@ -366,7 +456,11 @@ class Store { * * @returns Resource (Proxy) if in the cache, null otherwise */ - get(id: string, serverPagination?: ServerPaginationOptions, serverSearch?: ServerSearchOptions): Resource | null { + get( + id: string, + serverPagination?: ServerPaginationOptions, + serverSearch?: ServerSearchOptions, + ): Resource | null { if (serverPagination) { id = appendServerPaginationToIri(id, serverPagination); } @@ -378,7 +472,6 @@ class Store { return this.cache.get(id) || null; } - /** * Removes a resource from the cache * @param id - id of the resource to remove from the cache @@ -389,8 +482,9 @@ class Store { const resource = this.cache.get(id); if (resource['@type'] === 'ldp:Container') { resource['ldp:contains'].forEach((child: object) => { - if (child && child['@type'] === 'ldp:Container') this.cache.delete(child['@id']) - }) + if (child && child['@type'] === 'ldp:Container') + this.cache.delete(child['@id']); + }); } this.cache.delete(id); @@ -453,14 +547,16 @@ class Store { const deleted = await this.fetchAuthn(expandedId, { method: 'DELETE', headers: this.headers, - credentials: 'include' + credentials: 'include', }); - const resourcesToNotify = this.subscriptionIndex.get(expandedId) || []; - const resourcesToRefresh = this.subscriptionVirtualContainersIndex.get(expandedId) || []; + const resourcesToNotify = this.subscriptionIndex.get(expandedId) || []; + const resourcesToRefresh = + this.subscriptionVirtualContainersIndex.get(expandedId) || []; - this.refreshResources([...resourcesToNotify, ...resourcesToRefresh]) - .then(resourceIds => this.notifyResources(resourceIds)); + this.refreshResources([...resourcesToNotify, ...resourcesToRefresh]).then( + resourceIds => this.notifyResources(resourceIds), + ); return deleted; } @@ -472,14 +568,16 @@ class Store { */ _convertHeaders(headersObject: object): Headers { const headers = new Headers(); - for (const [key, value] of Object.entries(headersObject)){ + for (const [key, value] of Object.entries(headersObject)) { headers.set(key, value as string); } return headers; } _getExpandedId(id: string, context: object) { - return (context && Object.keys(context)) ? ContextParser.expandTerm(id, context) : id; + return context && Object.keys(context) + ? ContextParser.expandTerm(id, context) + : id; } /** @@ -489,9 +587,8 @@ class Store { * @returns The fully expanded term */ getExpandedPredicate(property: string, context: object | null) { - if (!context) - return ContextParser.expandTerm(property, base_context, true) - return ContextParser.expandTerm(property, context, true) + if (!context) return ContextParser.expandTerm(property, base_context, true); + return ContextParser.expandTerm(property, context, true); } /** @@ -501,9 +598,8 @@ class Store { * @returns The compacted term */ getCompactedIri(property: string, context: object | null) { - if (!context) - return ContextParser.compactIri(property, base_context, true) - return ContextParser.compactIri(property, context, true) + if (!context) return ContextParser.compactIri(property, base_context, true); + return ContextParser.compactIri(property, context, true); } /** @@ -521,8 +617,11 @@ class Store { * @param nestedResourceId - id of the resource which will change */ subscribeResourceTo(resourceId: string, nestedResourceId: string) { - const existingSubscriptions = this.subscriptionIndex.get(nestedResourceId) || []; - this.subscriptionIndex.set(nestedResourceId, [...new Set([...existingSubscriptions, resourceId])]) + const existingSubscriptions = + this.subscriptionIndex.get(nestedResourceId) || []; + this.subscriptionIndex.set(nestedResourceId, [ + ...new Set([...existingSubscriptions, resourceId]), + ]); } /** @@ -530,9 +629,15 @@ class Store { * @param virtualContainerId - id of the container which needs to be updated * @param nestedResourceId - id of the resource which will change */ - subscribeVirtualContainerTo(virtualContainerId: string, nestedResourceId: string) { - const existingSubscriptions = this.subscriptionVirtualContainersIndex.get(nestedResourceId) || []; - this.subscriptionVirtualContainersIndex.set(nestedResourceId, [...new Set([...existingSubscriptions, virtualContainerId])]) + subscribeVirtualContainerTo( + virtualContainerId: string, + nestedResourceId: string, + ) { + const existingSubscriptions = + this.subscriptionVirtualContainersIndex.get(nestedResourceId) || []; + this.subscriptionVirtualContainersIndex.set(nestedResourceId, [ + ...new Set([...existingSubscriptions, virtualContainerId]), + ]); } /** @@ -543,7 +648,8 @@ class Store { */ _getAbsoluteIri(id: string, context: object, parentId: string): string { let iri = ContextParser.expandTerm(id, context); // expand if reduced ids - if (parentId && !parentId.startsWith('store://local')) { // and get full URL from parent caller for local files + if (parentId && !parentId.startsWith('store://local')) { + // and get full URL from parent caller for local files let parentIri = new URL(parentId, document.location.href).href; iri = new URL(iri, parentIri).href; } else { @@ -563,7 +669,9 @@ class Store { * Return language of the users */ _getLanguage() { - return localStorage.getItem('language') || window.navigator.language.slice(0,2); + return ( + localStorage.getItem('language') || window.navigator.language.slice(0, 2) + ); } /** @@ -574,10 +682,10 @@ class Store { localStorage.setItem('language', selectedLanguageCode); } - resolveResource = function(id: string, resolve) { - const handler = function(event) { + resolveResource = function (id: string, resolve) { + const handler = function (event) { if (event.detail.id === id) { - if(event.detail.resource) { + if (event.detail.resource) { resolve(event.detail.resource); } else { resolve(event.detail.fetchedResource); @@ -595,18 +703,18 @@ if (window.sibStore) { store = window.sibStore; } else { const sibAuth = document.querySelector('sib-auth'); - const storeOptions: StoreOptions = {} + const storeOptions: StoreOptions = {}; if (sibAuth) { const sibAuthDefined = customElements.whenDefined(sibAuth.localName); - storeOptions.session = sibAuthDefined.then(() => (sibAuth as any).session) - storeOptions.fetchMethod = sibAuthDefined.then(() => (sibAuth as any).getFetch()) + storeOptions.session = sibAuthDefined.then(() => (sibAuth as any).session); + storeOptions.fetchMethod = sibAuthDefined.then(() => + (sibAuth as any).getFetch(), + ); } store = new Store(storeOptions); window.sibStore = store; } -export { - store -}; +export { store }; diff --git a/src/locales/en.json b/src/locales/en.json index 723755c3..c75d4106 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1,11 +1,11 @@ { - "autocompletion.placeholder": "Select a value", - "autocompletion.searchPlaceholder": "Search", - "autocompletion.searchText": "No result", - "solid-delete.button": "Delete", - "solid-form.submit-button": "Submit", - "solid-form.validation-error": "A validation error occurred.", - "validation.message": "Please, confirm your choice", - "validation.submit-text": "Yes", - "validation.cancel-text": "Cancel" -} \ No newline at end of file + "autocompletion.placeholder": "Select a value", + "autocompletion.searchPlaceholder": "Search", + "autocompletion.searchText": "No result", + "solid-delete.button": "Delete", + "solid-form.submit-button": "Submit", + "solid-form.validation-error": "A validation error occurred.", + "validation.message": "Please, confirm your choice", + "validation.submit-text": "Yes", + "validation.cancel-text": "Cancel" +} diff --git a/src/locales/fr.json b/src/locales/fr.json index d1c9c5fd..e2d66bf1 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -1,11 +1,11 @@ { - "autocompletion.placeholder": "Sélectionner une valeur", - "autocompletion.searchPlaceholder": "Rechercher", - "autocompletion.searchText": "Aucun résultat", - "solid-delete.button": "Supprimer", - "solid-form.submit-button": "Envoyer", - "solid-form.validation-error": "Erreur de validation.", - "validation.message": "Merci de confirmer votre choix", - "validation.submit-text": "Oui", - "validation.cancel-text": "Annuler" -} \ No newline at end of file + "autocompletion.placeholder": "Sélectionner une valeur", + "autocompletion.searchPlaceholder": "Rechercher", + "autocompletion.searchText": "Aucun résultat", + "solid-delete.button": "Supprimer", + "solid-form.submit-button": "Envoyer", + "solid-form.validation-error": "Erreur de validation.", + "validation.message": "Merci de confirmer votre choix", + "validation.submit-text": "Oui", + "validation.cancel-text": "Annuler" +} diff --git a/src/logger.ts b/src/logger.ts index 611723f1..59d3e178 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -1,192 +1,204 @@ import log from 'loglevel'; - const colors = { - reset: "\x1b[0m", - trace: "\x1b[38;2;169;169;169m", // Gray - debug: "\x1b[38;2;0;0;255m", // Blue - info: "\x1b[38;2;0;128;0m", // Green - warn: "\x1b[38;2;218;165;32m", // Yellow - error: "\x1b[38;2;255;0;0m", // Red + reset: '\x1b[0m', + trace: '\x1b[38;2;169;169;169m', // Gray + debug: '\x1b[38;2;0;0;255m', // Blue + info: '\x1b[38;2;0;128;0m', // Green + warn: '\x1b[38;2;218;165;32m', // Yellow + error: '\x1b[38;2;255;0;0m', // Red }; function formatMessage(level, messages) { - const timestamp = new Date().toISOString(); - const color = colors[level] || colors.reset; - - // Convert each message to a string, including objects - const formattedMessages = messages.map(msg => { - if (typeof msg === 'object') { - try { - return JSON.stringify(msg, null, 2); - } catch (error) { - return String(msg); - } + const timestamp = new Date().toISOString(); + const color = colors[level] || colors.reset; + + // Convert each message to a string, including objects + const formattedMessages = messages + .map(msg => { + if (typeof msg === 'object') { + try { + return JSON.stringify(msg, null, 2); + } catch (error) { + return String(msg); } - return String(msg); - }).join(' '); + } + return String(msg); + }) + .join(' '); - return `${color}[${timestamp}] ${formattedMessages}${colors.reset}`; + return `${color}[${timestamp}] ${formattedMessages}${colors.reset}`; } var originalFactory = log.methodFactory; log.methodFactory = function (methodName, logLevel, loggerName) { - const rawMethod = originalFactory(methodName, logLevel, loggerName); - return function (...messages) { - rawMethod(formatMessage(methodName, messages)); - }; + const rawMethod = originalFactory(methodName, logLevel, loggerName); + return function (...messages) { + rawMethod(formatMessage(methodName, messages)); + }; }; - // Manage the DEBUG environment variable if (import.meta.env?.VITE_DEBUG === 'True') { - log.setLevel('debug'); + log.setLevel('debug'); } else { - log.setLevel('warn'); + log.setLevel('warn'); } - // Async HOF to log render times and time execution export function trackRenderAsync(fn: Function, context?: string) { - return async function (...args: any[]) { - - let componentName = context ? context : this.name ? this.name : this.constructor.name; - if (this.element.id) { - componentName += ` (id: ${this.element.id})`; - } else if (this.dataSrc) { - componentName += ` (data-src: ${this.dataSrc})`; - } else if (this.resourceId) { - componentName += ` (resourceId: ${this.resourceId})`; - } - - const startTime = performance.now(); - const result = await fn.apply(this, args); - const endTime = performance.now(); - const renderTime = endTime - startTime; + return async function (...args: any[]) { + let componentName = context + ? context + : this.name + ? this.name + : this.constructor.name; + if (this.element.id) { + componentName += ` (id: ${this.element.id})`; + } else if (this.dataSrc) { + componentName += ` (data-src: ${this.dataSrc})`; + } else if (this.resourceId) { + componentName += ` (resourceId: ${this.resourceId})`; + } - if (this.profiler) { - this.profiler.updateStats(componentName, renderTime); - this.profiler.printStats() - } else { - log.debug(`Component ${componentName} rendered in ${renderTime.toFixed(2)} ms`); - } + const startTime = performance.now(); + const result = await fn.apply(this, args); + const endTime = performance.now(); + const renderTime = endTime - startTime; + + if (this.profiler) { + this.profiler.updateStats(componentName, renderTime); + this.profiler.printStats(); + } else { + log.debug( + `Component ${componentName} rendered in ${renderTime.toFixed(2)} ms`, + ); + } - return result; - }; + return result; + }; } - // HOF to log render times and time execution export function trackRender(fn: Function, context?: string) { - return async function (...args: any[]) { - - let componentName = context ? context : this.name ? this.name : this.constructor.name; - - if (this.element.id) { - componentName += ` (id: ${this.element.id})`; - } else if (this.dataSrc) { - componentName += ` (data-src: ${this.dataSrc})`; - } else if (this.resourceId) { - componentName += ` (resourceId: ${this.resourceId})`; - } - - const startTime = performance.now(); - const result = fn.apply(this, args); - const endTime = performance.now(); - const renderTime = endTime - startTime; + return async function (...args: any[]) { + let componentName = context + ? context + : this.name + ? this.name + : this.constructor.name; + + if (this.element.id) { + componentName += ` (id: ${this.element.id})`; + } else if (this.dataSrc) { + componentName += ` (data-src: ${this.dataSrc})`; + } else if (this.resourceId) { + componentName += ` (resourceId: ${this.resourceId})`; + } - if (this.profiler) { - this.profiler.updateStats(componentName, renderTime); - this.profiler.printStats() - } else { - log.debug(`Component ${componentName} rendered in ${renderTime.toFixed(2)} ms`); - } + const startTime = performance.now(); + const result = fn.apply(this, args); + const endTime = performance.now(); + const renderTime = endTime - startTime; + + if (this.profiler) { + this.profiler.updateStats(componentName, renderTime); + this.profiler.printStats(); + } else { + log.debug( + `Component ${componentName} rendered in ${renderTime.toFixed(2)} ms`, + ); + } - return result; - }; + return result; + }; } - export type PerformanceMetrics = { - renderCount: number; // Combien de fois le composant a été rendu - totalExecutionTime: number; // Temps total d'exécution (en ms) - lastExecutionTime: number; // Temps d'exécution lors du dernier rendu - averageExecutionTime: number; - minExecutionTime: number; - maxExecutionTime: number; + renderCount: number; // Combien de fois le composant a été rendu + totalExecutionTime: number; // Temps total d'exécution (en ms) + lastExecutionTime: number; // Temps d'exécution lors du dernier rendu + averageExecutionTime: number; + minExecutionTime: number; + maxExecutionTime: number; }; export class Profiler { - private stats: { [componentName: string]: PerformanceMetrics } = {}; - - constructor() { - this.stats = {}; - } - - private getOrCreateStats(componentName: string): PerformanceMetrics { - if (!this.stats[componentName]) { - this.stats[componentName] = { - renderCount: 0, - totalExecutionTime: 0, - lastExecutionTime: 0, - averageExecutionTime: 0, - minExecutionTime: Infinity, - maxExecutionTime: 0, - }; - } - return this.stats[componentName]; - } - - public getStats(componentName: string): PerformanceMetrics | undefined { - return this.stats[componentName]; + private stats: { [componentName: string]: PerformanceMetrics } = {}; + + constructor() { + this.stats = {}; + } + + private getOrCreateStats(componentName: string): PerformanceMetrics { + if (!this.stats[componentName]) { + this.stats[componentName] = { + renderCount: 0, + totalExecutionTime: 0, + lastExecutionTime: 0, + averageExecutionTime: 0, + minExecutionTime: Infinity, + maxExecutionTime: 0, + }; } - - public updateStats(componentName: string, renderTime: number): void { - const stats = this.getOrCreateStats(componentName); - stats.renderCount++; - stats.lastExecutionTime = renderTime; - stats.totalExecutionTime += renderTime; - stats.averageExecutionTime = stats.totalExecutionTime / stats.renderCount; - stats.minExecutionTime = Math.min(stats.minExecutionTime, renderTime); - stats.maxExecutionTime = Math.max(stats.maxExecutionTime, renderTime); + return this.stats[componentName]; + } + + public getStats(componentName: string): PerformanceMetrics | undefined { + return this.stats[componentName]; + } + + public updateStats(componentName: string, renderTime: number): void { + const stats = this.getOrCreateStats(componentName); + stats.renderCount++; + stats.lastExecutionTime = renderTime; + stats.totalExecutionTime += renderTime; + stats.averageExecutionTime = stats.totalExecutionTime / stats.renderCount; + stats.minExecutionTime = Math.min(stats.minExecutionTime, renderTime); + stats.maxExecutionTime = Math.max(stats.maxExecutionTime, renderTime); + } + + private formatTime(time: number): string { + if (time >= 1000) { + return `${(time / 1000).toFixed(2)} seconds`; + } else { + return `${time.toFixed(2)} ms`; } - - private formatTime(time: number): string { - if (time >= 1000) { - return `${(time / 1000).toFixed(2)} seconds`; - } else { - return `${time.toFixed(2)} ms`; - } - } - - private formatComponentStats(componentName: string, stats: PerformanceMetrics): string { - return `\nComponent: ${componentName}\n` + - ` Render Count: ${stats.renderCount}\n` + - ` Total Execution Time: ${this.formatTime(stats.totalExecutionTime)}\n` + - ` Last Execution Time: ${this.formatTime(stats.lastExecutionTime)}\n` + - ` Average Execution Time: ${this.formatTime(stats.averageExecutionTime)}\n` + - ` Min Execution Time: ${this.formatTime(stats.minExecutionTime)}\n` + - ` Max Execution Time: ${this.formatTime(stats.maxExecutionTime)}\n`; - } - - public printStats(componentName: string): void { - let output = 'Component Performance Stats:\n'; - - if (componentName) { - const stats = this.stats[componentName]; - if (!stats) { - output += `Component ${componentName} not found.\n`; - } else { - output += this.formatComponentStats(componentName, stats); - } - } else { - for (const [name, stats] of Object.entries(this.stats)) { - output += this.formatComponentStats(name, stats); - } - } - log.debug(output); + } + + private formatComponentStats( + componentName: string, + stats: PerformanceMetrics, + ): string { + return ( + `\nComponent: ${componentName}\n` + + ` Render Count: ${stats.renderCount}\n` + + ` Total Execution Time: ${this.formatTime(stats.totalExecutionTime)}\n` + + ` Last Execution Time: ${this.formatTime(stats.lastExecutionTime)}\n` + + ` Average Execution Time: ${this.formatTime(stats.averageExecutionTime)}\n` + + ` Min Execution Time: ${this.formatTime(stats.minExecutionTime)}\n` + + ` Max Execution Time: ${this.formatTime(stats.maxExecutionTime)}\n` + ); + } + + public printStats(componentName: string): void { + let output = 'Component Performance Stats:\n'; + + if (componentName) { + const stats = this.stats[componentName]; + if (!stats) { + output += `Component ${componentName} not found.\n`; + } else { + output += this.formatComponentStats(componentName, stats); + } + } else { + for (const [name, stats] of Object.entries(this.stats)) { + output += this.formatComponentStats(name, stats); + } } + log.debug(output); + } } -export { log as logger } \ No newline at end of file +export { log as logger }; diff --git a/src/mixins/attributeBinderMixin.ts b/src/mixins/attributeBinderMixin.ts index 21c0b3c7..e410d8f9 100644 --- a/src/mixins/attributeBinderMixin.ts +++ b/src/mixins/attributeBinderMixin.ts @@ -5,7 +5,7 @@ const AttributeBinderMixin = { name: 'attribute-binder-mixin', use: [], initialState: { - bindedAttributes: null + bindedAttributes: null, }, created() { this.bindedAttributes = {}; @@ -27,12 +27,13 @@ const AttributeBinderMixin = { const oldAttributes: any = Array.from(this.element.attributes) // transform NamedNodeMap in object .reduce((obj: any, attr: any) => { - // Keep only attributes starting with `store://...` - if (!attr.value.match(/^store:\/\/(resource|container|user)/)) return { ...obj } + if (!attr.value.match(/^store:\/\/(resource|container|user)/)) + return { ...obj }; // Save attr for reset later - if (!this.bindedAttributes[attr.name]) this.bindedAttributes[attr.name] = attr.value; + if (!this.bindedAttributes[attr.name]) + this.bindedAttributes[attr.name] = attr.value; return { ...obj, @@ -40,9 +41,13 @@ const AttributeBinderMixin = { }; }, {}); - const newAttributes = await this.transformAttributes({ ...oldAttributes }, this.resource); // generate new attributes + const newAttributes = await this.transformAttributes( + { ...oldAttributes }, + this.resource, + ); // generate new attributes - for (let attr of Object.keys(newAttributes)) { // set attributes on element + for (let attr of Object.keys(newAttributes)) { + // set attributes on element if (oldAttributes[attr] == newAttributes[attr]) continue; // only if it changed this.element.setAttribute(attr, newAttributes[attr]); } @@ -62,17 +67,27 @@ const AttributeBinderMixin = { // Avoid error if value is a number if (typeof value === 'string') { // Replace attribute value - if (!isContainer && resource && value.startsWith('store://resource')) { // RESOURCE + if (!isContainer && resource && value.startsWith('store://resource')) { + // RESOURCE let path = value.replace('store://resource.', ''); attributes[attr] = resource ? await resource[path] : ''; - } else if (isContainer && resource && value.startsWith('store://container')) { // CONTAINER + } else if ( + isContainer && + resource && + value.startsWith('store://container') + ) { + // CONTAINER let path = value.replace('store://container.', ''); attributes[attr] = resource ? await resource[path] : ''; - } else if (value.startsWith('store://user')) { // USER + } else if (value.startsWith('store://user')) { + // USER // retry until sibAuth is defined const userId = await this.retry(this.getUser.bind(this)); // TODO: Using this.context makes no sense here. Use same-attribute-context="context-id" instead? - const user = userId && userId['@id'] ? await store.getData(userId['@id'], this.context || base_context) : null; + const user = + userId && userId['@id'] + ? await store.getData(userId['@id'], this.context || base_context) + : null; if (!user) { attributes[attr] = ''; continue; @@ -104,17 +119,17 @@ const AttributeBinderMixin = { async retry(fn: Function, ms = 200, maxRetries = 5) { return new Promise((resolve, reject) => { let retries = 0; - fn().then(resolve).catch(() => { - setTimeout(() => { - ++retries; - if (retries == maxRetries) return reject(); - this.retry(fn, ms).then(resolve); - }, ms); - }); + fn() + .then(resolve) + .catch(() => { + setTimeout(() => { + ++retries; + if (retries == maxRetries) return reject(); + this.retry(fn, ms).then(resolve); + }, ms); + }); }); - } -} + }, +}; -export { - AttributeBinderMixin -} \ No newline at end of file +export { AttributeBinderMixin }; diff --git a/src/mixins/contextMixin.ts b/src/mixins/contextMixin.ts index 310408a4..5a8e947a 100644 --- a/src/mixins/contextMixin.ts +++ b/src/mixins/contextMixin.ts @@ -6,22 +6,22 @@ const ContextMixin = { attributes: { extraContext: { type: String, - default: null + default: null, }, }, get context(): object { return { ...base_context, ...this.extra_context }; }, get extra_context(): object { - let extraContextElement = this.extraContext ? - document.getElementById(this.extraContext) : // take element extra context first - document.querySelector('[data-default-context]'); // ... or look for a default extra context + let extraContextElement = this.extraContext + ? document.getElementById(this.extraContext) + : // take element extra context first + document.querySelector('[data-default-context]'); // ... or look for a default extra context - if (extraContextElement) return JSON.parse(extraContextElement.textContent || "{}"); + if (extraContextElement) + return JSON.parse(extraContextElement.textContent || '{}'); return {}; }, }; -export { - ContextMixin -} \ No newline at end of file +export { ContextMixin }; diff --git a/src/mixins/counterMixin.ts b/src/mixins/counterMixin.ts index 0bfcc4ae..edb4cdac 100644 --- a/src/mixins/counterMixin.ts +++ b/src/mixins/counterMixin.ts @@ -3,14 +3,13 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js'; import { evalTemplateString } from '../libs/helpers'; import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; - const CounterMixin = { name: 'counter-mixin', use: [], attributes: { counterTemplate: { type: String, - default: null + default: null, }, }, initialState: { @@ -18,19 +17,29 @@ const CounterMixin = { parentCounterDiv: null, }, attached() { - this.listPostProcessors.attach(this.countResources.bind(this), 'CounterMixin:countResources'); + this.listPostProcessors.attach( + this.countResources.bind(this), + 'CounterMixin:countResources', + ); }, - async countResources(resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string) { + async countResources( + resources: object[], + listPostProcessors: PostProcessorRegistry, + div: HTMLElement, + context: string, + ) { if (this.counterTemplate) { this.initParentCounterDiv(div); - this.renderCallbacks.push({ // add counter template to render callback + this.renderCallbacks.push({ + // add counter template to render callback template: await this.renderCounter(resources.length), - parent: this.parentCounterDiv + parent: this.parentCounterDiv, }); } const nextProcessor = listPostProcessors.shift(); - if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context); + if (nextProcessor) + await nextProcessor(resources, listPostProcessors, div, context); }, /** * Create the parent div of the counter in the component. @@ -52,9 +61,7 @@ const CounterMixin = { throw e; } return html`${unsafeHTML(htmlCounter)}`; - } -} + }, +}; -export { - CounterMixin -} \ No newline at end of file +export { CounterMixin }; diff --git a/src/mixins/federationMixin.ts b/src/mixins/federationMixin.ts index cb1013fc..d9748935 100644 --- a/src/mixins/federationMixin.ts +++ b/src/mixins/federationMixin.ts @@ -6,18 +6,27 @@ const FederationMixin = { name: 'federation-mixin', use: [], initialState: { - containerFetched: null + containerFetched: null, }, attached(): void { - this.listPostProcessors.attach(this.fetchSources.bind(this), 'FederationMixin:fetchSources'); + this.listPostProcessors.attach( + this.fetchSources.bind(this), + 'FederationMixin:fetchSources', + ); }, - async fetchSources(resources: Resource[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string) { + async fetchSources( + resources: Resource[], + listPostProcessors: PostProcessorRegistry, + div: HTMLElement, + context: string, + ) { this.containerFetched = []; let newResources: Resource[] = await this.getResources(resources); newResources = [...new Set(newResources)]; // remove possible duplicates const nextProcessor = listPostProcessors.shift(); - if (nextProcessor) await nextProcessor(newResources, listPostProcessors, div, context); + if (nextProcessor) + await nextProcessor(newResources, listPostProcessors, div, context); }, async getResources(resources: Resource[]): Promise<Resource[]> { if (!resources) return []; @@ -25,18 +34,21 @@ const FederationMixin = { const getChildResources = async (res: Resource) => { if (!res) return; - if (res.isContainer?.()) { // if this is a container + if (res.isContainer?.()) { + // if this is a container const containerId = res['@id']; - if (!this.containerFetched.includes(containerId)) { // prevent from including twice the same source + if (!this.containerFetched.includes(containerId)) { + // prevent from including twice the same source this.containerFetched.push(containerId); const resourcesFetched = await this.fetchSource(containerId); // fetch the resources of this container - if (resourcesFetched) newResources.push(...(await this.getResources(resourcesFetched))); // Add content of source to array... + if (resourcesFetched) + newResources.push(...(await this.getResources(resourcesFetched))); // Add content of source to array... } } else { newResources.push(res); // Or resource directly if not a container } - } + }; // Special case for list support, if there is only one item it is serialized as an object, not an array if (!Array.isArray(resources)) resources = [resources]; @@ -46,14 +58,13 @@ const FederationMixin = { async fetchSource(containerId: string): Promise<Resource[] | null> { const cachedContainer = store.get(containerId); // find container in cache - if (!cachedContainer || cachedContainer['ldp:contains'] === null) { // if container not fetched + if (!cachedContainer || cachedContainer['ldp:contains'] === null) { + // if container not fetched store.clearCache(containerId); // empty cache } const container = await store.getData(containerId, this.context); // and fetch it return container ? container['ldp:contains'] : null; }, -} +}; -export { - FederationMixin -} \ No newline at end of file +export { FederationMixin }; diff --git a/src/mixins/filterMixin.ts b/src/mixins/filterMixin.ts index 0921aafd..6af9f2c1 100644 --- a/src/mixins/filterMixin.ts +++ b/src/mixins/filterMixin.ts @@ -12,23 +12,27 @@ const FilterMixin = { attributes: { searchFields: { type: String, - default: null + default: null, }, filteredBy: { type: String, default: null, callback(newValue: string) { // if we change search form, re-populate - if (newValue && this.searchForm && newValue !== this.searchForm.getAttribute('id')) { + if ( + newValue && + this.searchForm && + newValue !== this.searchForm.getAttribute('id') + ) { this.searchForm.component.detach(this); this.searchForm = null; this.populate(); } - } + }, }, filteredOn: { type: String, // 'server' | 'client' - default: 'client' + default: 'client', }, }, created() { @@ -36,17 +40,22 @@ const FilterMixin = { this.element.addEventListener('populate', () => { if (!window.document.contains(this.element)) return; this.searchForm?.component.updateAutoRanges(); - }) + }); }, attached(): void { const filteredBy = this.filteredBy; if (this.isFilteredOnServer() && filteredBy) { - this.searchForm = document.getElementById(filteredBy) + this.searchForm = document.getElementById(filteredBy); if (!this.searchForm) throw `#${filteredBy} is not in DOM`; // this.searchForm.component.attach(this); // is it necessary? - this.searchForm.addEventListener('formChange', () => this.onServerSearchChange()); + this.searchForm.addEventListener('formChange', () => + this.onServerSearchChange(), + ); } else { - this.listPostProcessors.attach(this.filterCallback.bind(this), 'FilterMixin:filterCallback'); + this.listPostProcessors.attach( + this.filterCallback.bind(this), + 'FilterMixin:filterCallback', + ); } }, get filters(): SearchQuery { @@ -72,15 +81,21 @@ const FilterMixin = { const fields = Object.keys(filters); const value = (Object.values(filters) as { value: string }[]) .map(({ value }) => value) - .filter((value) => !!value) - .join(' ').trim(); + .filter(value => !!value) + .join(' ') + .trim(); if (fields.length > 0 && value) { return { fields, value }; } } return; }, - async filterCallback(resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string): Promise<void> { + async filterCallback( + resources: object[], + listPostProcessors: PostProcessorRegistry, + div: HTMLElement, + context: string, + ): Promise<void> { if (this.filteredBy || this.searchFields) { if (!this.searchCount.has(context)) this.searchCount.set(context, 1); if (!this.searchForm) await this.createFilter(context); @@ -88,13 +103,19 @@ const FilterMixin = { resources, this.filters, this.fields, - this.searchForm + this.searchForm, ); resources = resources.filter((_v, index) => filteredResources[index]); } const nextProcessor = listPostProcessors.shift(); - if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context + (this.searchCount.get(context) || '')); + if (nextProcessor) + await nextProcessor( + resources, + listPostProcessors, + div, + context + (this.searchCount.get(context) || ''), + ); }, async filterList(context: string): Promise<void> { this.searchCount.set(context, this.searchCount.get(context) + 1); @@ -110,8 +131,10 @@ const FilterMixin = { const nextArrayOfObjects = await obj[field]; if (!nextArrayOfObjects) continue; - if (typeof nextArrayOfObjects !== "object") { - console.warn(`The format value of ${field} is not suitable with auto-range-[field] attribute`); + if (typeof nextArrayOfObjects !== 'object') { + console.warn( + `The format value of ${field} is not suitable with auto-range-[field] attribute`, + ); continue; } @@ -131,7 +154,7 @@ const FilterMixin = { async createFilter(context: string): Promise<void> { const filteredBy = this.filteredBy; if (filteredBy != null) { - this.searchForm = document.getElementById(filteredBy) + this.searchForm = document.getElementById(filteredBy); if (!this.searchForm) throw `#${filteredBy} is not in DOM`; } else { this.searchForm = document.createElement(`solid-form-search`); @@ -159,8 +182,6 @@ const FilterMixin = { this.element.insertBefore(this.searchForm, this.element.firstChild); await this.searchForm.component.populate(); }, -} +}; -export { - FilterMixin -} \ No newline at end of file +export { FilterMixin }; diff --git a/src/mixins/grouperMixin.ts b/src/mixins/grouperMixin.ts index 1a16d18f..1e3d013d 100644 --- a/src/mixins/grouperMixin.ts +++ b/src/mixins/grouperMixin.ts @@ -1,4 +1,4 @@ -import { generalComparator } from "../libs/helpers"; +import { generalComparator } from '../libs/helpers'; import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const GrouperMixin = { @@ -11,25 +11,33 @@ const GrouperMixin = { }, groupWidget: { type: String, - default: 'solid-group-default' + default: 'solid-group-default', }, groupClass: { type: String, - default: '' + default: '', }, orderGroupAsc: { type: Boolean, - default: null + default: null, }, orderGroupDesc: { type: Boolean, - default: null + default: null, }, }, attached() { - this.listPostProcessors.attach(this.groupResources.bind(this), 'GrouperMixin:groupResources'); + this.listPostProcessors.attach( + this.groupResources.bind(this), + 'GrouperMixin:groupResources', + ); }, - async groupResources(resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string) { + async groupResources( + resources: object[], + listPostProcessors: PostProcessorRegistry, + div: HTMLElement, + context: string, + ) { const nextProcessor = listPostProcessors.shift(); if (this.groupBy) { let groups = {}; @@ -37,34 +45,34 @@ const GrouperMixin = { const valueGroup = await resource[this.groupBy]; if (valueGroup == null) continue; if (!groups[valueGroup]) groups[valueGroup] = { resources: [] }; // if no group yet, we create one... - groups[valueGroup].resources.push(resource) // ...and push corresponding resource into it + groups[valueGroup].resources.push(resource); // ...and push corresponding resource into it } let sortedKeys = Object.keys(groups); if (this.orderGroupAsc !== null || this.orderGroupDesc !== null) { - const order = this.orderGroupDesc !== null ? 'desc' : 'asc' + const order = this.orderGroupDesc !== null ? 'desc' : 'asc'; sortedKeys = Object.keys(groups).sort((a, b) => { - return generalComparator(a, b, order); + return generalComparator(a, b, order); }); } // For each group, get group widget and call next processors - const parents = sortedKeys.map(g => ({ group: g, parent: this.renderGroup(g, div) })); + const parents = sortedKeys.map(g => ({ + group: g, + parent: this.renderGroup(g, div), + })); for (let { group, parent } of parents) { - if (nextProcessor) await nextProcessor( - groups[group].resources, // give only resources from group - listPostProcessors.deepCopy(), // copy post processors - parent, // parent is group widget - context + "_" + group - ); + if (nextProcessor) + await nextProcessor( + groups[group].resources, // give only resources from group + listPostProcessors.deepCopy(), // copy post processors + parent, // parent is group widget + context + '_' + group, + ); } } else { - if (nextProcessor) await nextProcessor( - resources, - listPostProcessors, - div, - context - ); + if (nextProcessor) + await nextProcessor(resources, listPostProcessors, div, context); } }, /** @@ -72,7 +80,9 @@ const GrouperMixin = { * @param groupName */ renderGroup(groupName: string, div: HTMLElement) { - let groupElt = this.element.querySelector(`${this.groupWidget}[value="${groupName}"]`); + let groupElt = this.element.querySelector( + `${this.groupWidget}[value="${groupName}"]`, + ); if (!groupElt) { groupElt = document.createElement(this.groupWidget); groupElt.setAttribute('value', groupName); @@ -81,9 +91,7 @@ const GrouperMixin = { div.appendChild(groupElt); // and append it to the parent div } return groupElt.querySelector('[data-content]') || groupElt; // return the node where to insert content - } -} + }, +}; -export { - GrouperMixin -} \ No newline at end of file +export { GrouperMixin }; diff --git a/src/mixins/highlighterMixin.ts b/src/mixins/highlighterMixin.ts index 1e19135d..d6e39c82 100644 --- a/src/mixins/highlighterMixin.ts +++ b/src/mixins/highlighterMixin.ts @@ -1,26 +1,37 @@ -import { PostProcessorRegistry } from "../libs/PostProcessorRegistry"; +import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const HighlighterMixin = { name: 'highlighter-mixin', use: [], attached(): void { - this.listPostProcessors.attach(this.hightlightCallback.bind(this), 'HighlighterMixin:hightlightCallback'); + this.listPostProcessors.attach( + this.hightlightCallback.bind(this), + 'HighlighterMixin:hightlightCallback', + ); }, - async hightlightCallback(resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string): Promise<void> { + async hightlightCallback( + resources: object[], + listPostProcessors: PostProcessorRegistry, + div: HTMLElement, + context: string, + ): Promise<void> { for (let attr of this.element.attributes) { if (attr.name.startsWith('highlight-')) { const field = attr.name.split('highlight-')[1]; - resources = await Promise.all(resources.map(async (resource) => ({ - sortingKey: await resource[field], // fetch sorting value - proxy: resource // and keep proxy - }))); - resources = this.sortHighlighted(resources, "sortingKey", attr.value); // highlight element + resources = await Promise.all( + resources.map(async resource => ({ + sortingKey: await resource[field], // fetch sorting value + proxy: resource, // and keep proxy + })), + ); + resources = this.sortHighlighted(resources, 'sortingKey', attr.value); // highlight element resources = resources.map(resource => (<any>resource).proxy); // and re-transform in arra of resources } } const nextProcessor = listPostProcessors.shift(); - if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context); + if (nextProcessor) + await nextProcessor(resources, listPostProcessors, div, context); }, sortHighlighted(resources, field, value) { @@ -30,10 +41,8 @@ const HighlighterMixin = { resources.splice(0, 0, resources.splice(index, 1)[0]); // TODO : test with sort } } - return resources - } -} + return resources; + }, +}; -export { - HighlighterMixin -} \ No newline at end of file +export { HighlighterMixin }; diff --git a/src/mixins/interfaces.ts b/src/mixins/interfaces.ts index 1ed067a4..61a51c7d 100644 --- a/src/mixins/interfaces.ts +++ b/src/mixins/interfaces.ts @@ -1,20 +1,20 @@ export enum WidgetType { - CUSTOM = "custom", - USER = "user", - NATIVE = "native", + CUSTOM = 'custom', + USER = 'user', + NATIVE = 'native', } export interface WidgetInterface { - tagName: String - type: WidgetType + tagName: String; + type: WidgetType; } export interface Resource { - '@id': string - clientContext: object - isContainer: Function - isArray: Function - isFullResource: Function - properties: string[], - serverPagination: object -} \ No newline at end of file + '@id': string; + clientContext: object; + isContainer: Function; + isArray: Function; + isFullResource: Function; + properties: string[]; + serverPagination: object; +} diff --git a/src/mixins/listMixin.ts b/src/mixins/listMixin.ts index 40180914..0501f9cf 100644 --- a/src/mixins/listMixin.ts +++ b/src/mixins/listMixin.ts @@ -30,14 +30,14 @@ const ListMixin = { this.appendChildElt(this.resource['@id'], parent); }, setElementAttribute(attr: 'resource' | 'container') { - const containerAttribute = "solid-container"; - const resourceAttribute = "solid-resource"; - if (attr === "resource") { + const containerAttribute = 'solid-container'; + const resourceAttribute = 'solid-resource'; + if (attr === 'resource') { this.element.removeAttribute(containerAttribute); - this.element.setAttribute(resourceAttribute, ""); + this.element.setAttribute(resourceAttribute, ''); } else { this.element.removeAttribute(resourceAttribute); - this.element.setAttribute(containerAttribute, "") + this.element.setAttribute(containerAttribute, ''); } }, async populate(): Promise<void> { @@ -46,32 +46,52 @@ const ListMixin = { if (!this.resource) return; // Not a container but a single resource - if (!this.resource.isContainer?.() && !this.arrayField && !this.predicateName) { - this.setElementAttribute("resource"); + if ( + !this.resource.isContainer?.() && + !this.arrayField && + !this.predicateName + ) { + this.setElementAttribute('resource'); this.appendSingleElt(div); return; } if (this.resource.isContainer?.()) { - this.setElementAttribute("container"); + this.setElementAttribute('container'); this.renderCallbacks = []; - listPostProcessorsCopy.attach(this.renderDOM.bind(this), 'ListMixin:renderDOM'); - listPostProcessorsCopy.attach(this.handleEmptyWidget.bind(this), 'ListMixin:handleEmptyWidget'); + listPostProcessorsCopy.attach( + this.renderDOM.bind(this), + 'ListMixin:renderDOM', + ); + listPostProcessorsCopy.attach( + this.handleEmptyWidget.bind(this), + 'ListMixin:handleEmptyWidget', + ); // Execute the first post-processor of the list const nextProcessor = listPostProcessorsCopy.shift(); - + await nextProcessor( this.resource['ldp:contains'], listPostProcessorsCopy, div, this.dataSrc, ); - } else if (this.arrayField && this.predicateName && this.resource[this.predicateName]) { - this.setElementAttribute("container"); + } else if ( + this.arrayField && + this.predicateName && + this.resource[this.predicateName] + ) { + this.setElementAttribute('container'); this.renderCallbacks = []; - listPostProcessorsCopy.attach(this.renderDOM.bind(this), 'ListMixin:renderDOM'); - listPostProcessorsCopy.attach(this.handleEmptyWidget.bind(this), 'ListMixin:handleEmptyWidget'); + listPostProcessorsCopy.attach( + this.renderDOM.bind(this), + 'ListMixin:renderDOM', + ); + listPostProcessorsCopy.attach( + this.handleEmptyWidget.bind(this), + 'ListMixin:handleEmptyWidget', + ); // Execute the first post-processor of the list const nextProcessor = listPostProcessorsCopy.shift(); @@ -82,14 +102,12 @@ const ListMixin = { div, this.dataSrc, ); - } // Execute the render callbacks for (const renderCallback of this.renderCallbacks) { // Render the template in the given parent element render(renderCallback.template, renderCallback.parent); } - }, /** @@ -113,12 +131,7 @@ const ListMixin = { const nextProcessor = listPostProcessors.shift(); if (nextProcessor) - await nextProcessor( - resources, - listPostProcessors, - div, - context - ); + await nextProcessor(resources, listPostProcessors, div, context); }, /** @@ -135,23 +148,21 @@ const ListMixin = { context: string, ) { if (this.emptyWidget) { - const emptyWidgetTemplate = preHTML`<${this.emptyWidget} value=${ifDefined(this.emptyValue)}></${this.emptyWidget}>` + const emptyWidgetTemplate = preHTML`<${this.emptyWidget} value=${ifDefined(this.emptyValue)}></${this.emptyWidget}>`; if (!this.emptyWrapper) { - this.emptyWrapper = document.createElement('span') - this.element.appendChild(this.emptyWrapper) + this.emptyWrapper = document.createElement('span'); + this.element.appendChild(this.emptyWrapper); } - render(resources.length > 0 ? html`` : emptyWidgetTemplate, this.emptyWrapper); + render( + resources.length > 0 ? html`` : emptyWidgetTemplate, + this.emptyWrapper, + ); } const nextProcessor = listPostProcessors.shift(); if (nextProcessor) - await nextProcessor( - resources, - listPostProcessors, - div, - context - ); + await nextProcessor(resources, listPostProcessors, div, context); }, }; diff --git a/src/mixins/nextMixin.ts b/src/mixins/nextMixin.ts index d3663f73..eab388ce 100644 --- a/src/mixins/nextMixin.ts +++ b/src/mixins/nextMixin.ts @@ -1,4 +1,4 @@ -import type { Resource } from "./interfaces.js"; +import type { Resource } from './interfaces.js'; const NextMixin = { name: 'next-mixin', @@ -6,7 +6,7 @@ const NextMixin = { attributes: { next: { type: String, - default:'' + default: '', }, }, @@ -20,9 +20,7 @@ const NextMixin = { }), ); } - } -} + }, +}; -export { - NextMixin -} \ No newline at end of file +export { NextMixin }; diff --git a/src/mixins/paginateMixin.ts b/src/mixins/paginateMixin.ts index 105ab4e2..64ba4254 100644 --- a/src/mixins/paginateMixin.ts +++ b/src/mixins/paginateMixin.ts @@ -1,5 +1,5 @@ -import { html, TemplateResult } from "lit"; -import { PostProcessorRegistry } from "../libs/PostProcessorRegistry"; +import { html, TemplateResult } from 'lit'; +import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const PaginateMixin = { name: 'paginate-mixin', @@ -7,12 +7,12 @@ const PaginateMixin = { attributes: { paginateBy: { type: Number, - default: 0 + default: 0, }, paginateLoop: { type: String, - default: null - } + default: null, + }, }, initialState: { currentPage: [], @@ -21,23 +21,40 @@ const PaginateMixin = { this.currentPage = []; }, attached(): void { - this.listPostProcessors.attach(this.paginateCallback.bind(this), 'PaginateMixin:paginateCallback'); + this.listPostProcessors.attach( + this.paginateCallback.bind(this), + 'PaginateMixin:paginateCallback', + ); }, - async paginateCallback(resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string) { + async paginateCallback( + resources: object[], + listPostProcessors: PostProcessorRegistry, + div: HTMLElement, + context: string, + ) { if (this.paginateBy > 0) { if (!this.currentPage[context]) this.currentPage[context] = 1; const parentDiv = this.initParentPaginationDiv(div, context); this.renderCallbacks.push({ - template: this.renderPaginationNav(this.getPageCount(resources.length),context,div), - parent: parentDiv + template: this.renderPaginationNav( + this.getPageCount(resources.length), + context, + div, + ), + parent: parentDiv, }); - const firstElementIndex = (this.getCurrentPage(context) - 1) * this.paginateBy; - resources = resources.slice(firstElementIndex, firstElementIndex + this.paginateBy); + const firstElementIndex = + (this.getCurrentPage(context) - 1) * this.paginateBy; + resources = resources.slice( + firstElementIndex, + firstElementIndex + this.paginateBy, + ); } const nextProcessor = listPostProcessors.shift(); - if (nextProcessor) await nextProcessor(resources, listPostProcessors, div,context); + if (nextProcessor) + await nextProcessor(resources, listPostProcessors, div, context); }, getNavElement(div: HTMLElement) { const insertNode = div.parentNode || div; @@ -79,7 +96,11 @@ const PaginateMixin = { * @param pageCount * @param context */ - renderPaginationNav(pageCount: number, context: string, div: HTMLElement): TemplateResult { + renderPaginationNav( + pageCount: number, + context: string, + div: HTMLElement, + ): TemplateResult { this.getNavElement(div).toggleAttribute('hidden', pageCount <= 1); const currentPage = this.getCurrentPage(context); @@ -92,15 +113,13 @@ const PaginateMixin = { <button data-id="next" ?disabled=${!this.shouldLoop() && currentPage >= pageCount} - @click=${ () => this.setCurrentPage(currentPage + 1, context, pageCount)} + @click=${() => this.setCurrentPage(currentPage + 1, context, pageCount)} >→</button> <span> <span data-id="current">${currentPage}</span> / <span data-id="count">${String(pageCount)}</span> </span> `; }, -} +}; -export { - PaginateMixin -} \ No newline at end of file +export { PaginateMixin }; diff --git a/src/mixins/requiredMixin.ts b/src/mixins/requiredMixin.ts index 04c6d193..8a86e657 100644 --- a/src/mixins/requiredMixin.ts +++ b/src/mixins/requiredMixin.ts @@ -1,22 +1,33 @@ -import { PostProcessorRegistry } from "../libs/PostProcessorRegistry"; +import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const RequiredMixin = { name: 'required-mixin', use: [], attached(): void { - this.listPostProcessors.attach(this.requiredResources.bind(this), 'RequiredMixin:requiredResources'); + this.listPostProcessors.attach( + this.requiredResources.bind(this), + 'RequiredMixin:requiredResources', + ); }, - async requiredResources(resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string): Promise<void> { + async requiredResources( + resources: object[], + listPostProcessors: PostProcessorRegistry, + div: HTMLElement, + context: string, + ): Promise<void> { const displays: any[] = []; - const requiredFields = Array.from((this.element as Element).attributes).filter(attr => attr.name.startsWith('required-')) + const requiredFields = Array.from((this.element as Element).attributes) + .filter(attr => attr.name.startsWith('required-')) .map(attr => { - return (attr.value !== '' ? attr.value : attr['name'].replace('required-', '')); - }); + return attr.value !== '' + ? attr.value + : attr['name'].replace('required-', ''); + }); if (requiredFields.length) { for (let resource of resources) { let hasProps = true; - for(let field of requiredFields) { + for (let field of requiredFields) { // Retrieve resource from store let res = await resource[field]; if (!res || res == null) { @@ -28,10 +39,14 @@ const RequiredMixin = { } } const nextProcessor = listPostProcessors.shift(); - if (nextProcessor) await nextProcessor(requiredFields.length ? displays : resources, listPostProcessors, div, context); - } -} + if (nextProcessor) + await nextProcessor( + requiredFields.length ? displays : resources, + listPostProcessors, + div, + context, + ); + }, +}; -export { - RequiredMixin -} +export { RequiredMixin }; diff --git a/src/mixins/serverPaginationMixin.ts b/src/mixins/serverPaginationMixin.ts index 815145ca..30c0a354 100644 --- a/src/mixins/serverPaginationMixin.ts +++ b/src/mixins/serverPaginationMixin.ts @@ -1,4 +1,4 @@ -import { html, render } from "lit"; +import { html, render } from 'lit'; const ServerPaginationMixin = { name: 'server-pagination-mixin', @@ -6,20 +6,20 @@ const ServerPaginationMixin = { attributes: { limit: { type: Number, - default: undefined + default: undefined, }, offset: { type: Number, - default: undefined + default: undefined, }, pageCount: { type: Number, - default: 1000 + default: 1000, }, pageNumber: { type: Number, - default: 0 - } + default: 0, + }, }, initialState: { currentOffset: [], @@ -29,20 +29,20 @@ const ServerPaginationMixin = { if (this.limit) { this.setCurrentOffset(this.resourceId, 0); const parentDiv = this.initServerPaginationDiv(this.div); - + this.renderCallbacks.push({ template: this.renderServerPaginationNav(this.resourceId, parentDiv), - parent: parentDiv + parent: parentDiv, }); } }, getCurrentOffset(resourceId: string, limit: number) { - return this.currentOffset[resourceId + "#p" + limit]; + return this.currentOffset[resourceId + '#p' + limit]; }, async setCurrentOffset(resourceId: string, offset: number): Promise<void> { - let index = resourceId + "#p" + this.limit; + let index = resourceId + '#p' + this.limit; this.currentOffset[index] = this.offset = offset; this.pageNumber = Number(this.offset / this.limit); this.currentPage[resourceId] = this.pageNumber; @@ -51,7 +51,7 @@ const ServerPaginationMixin = { }, async decreaseCurrentOffset(resourceId: string): Promise<void> { - let index = resourceId + "#p" + this.limit; + let index = resourceId + '#p' + this.limit; this.currentOffset[index] = this.offset = this.offset - this.limit; this.currentPage[index] = this.offset / this.limit; this.pageNumber = this.offset / this.limit; @@ -61,7 +61,7 @@ const ServerPaginationMixin = { }, async increaseCurrentOffset(resourceId: string): Promise<void> { - let index = resourceId + "#p" + this.limit; + let index = resourceId + '#p' + this.limit; this.currentOffset[index] = this.offset = this.offset + this.limit; this.currentPage[index] = this.offset / this.limit; @@ -70,14 +70,15 @@ const ServerPaginationMixin = { }, async updateNavButtons(resourceId: string, index: string, variance: number) { - this.element.querySelector("[data-id='prev']").disabled = this.currentOffset[index] <= 0; + this.element.querySelector("[data-id='prev']").disabled = + this.currentOffset[index] <= 0; // this.element.querySelector("[data-id='next']").disabled = await this.resource['ldp:contains'].length == 0; - this.element.querySelector("[data-id='current']").innerText = this.getCurrentServedPage(resourceId, variance); - + this.element.querySelector("[data-id='current']").innerText = + this.getCurrentServedPage(resourceId, variance); }, getServerNavElement(div: HTMLElement) { - if(div) { + if (div) { const insertNode = div.parentNode || div; return insertNode.querySelector(`nav[data-id="nav"]`); } @@ -95,7 +96,7 @@ const ServerPaginationMixin = { * Find nav element or create it if not existing * @param div - insert nav next to this div */ - initServerPaginationDiv(div: HTMLElement) { + initServerPaginationDiv(div: HTMLElement) { let nav = this.getServerNavElement(div); if (!nav) { nav = document.createElement('nav'); @@ -115,7 +116,8 @@ const ServerPaginationMixin = { var currentPageNumber = this.getCurrentServedPage(resourceId, 1); const pageCount = Math.ceil(this.pageCount / this.limit); - render(html` + render( + html` <button data-id="prev" ?disabled=${currentOffset <= 0} @@ -127,15 +129,15 @@ const ServerPaginationMixin = { <button data-id="next" ?disabled=${currentOffset >= (pageCount - 1) * this.limit} - @click=${ () => this.increaseCurrentOffset(resourceId)} + @click=${() => this.increaseCurrentOffset(resourceId)} >→</button> <span> </span> - `, div); + `, + div, + ); } }, -} +}; -export { - ServerPaginationMixin -} \ No newline at end of file +export { ServerPaginationMixin }; diff --git a/src/mixins/sorterMixin.ts b/src/mixins/sorterMixin.ts index a048d249..1b2f454d 100644 --- a/src/mixins/sorterMixin.ts +++ b/src/mixins/sorterMixin.ts @@ -1,4 +1,4 @@ -import { PostProcessorRegistry } from "../libs/PostProcessorRegistry"; +import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const SorterMixin = { name: 'sorter-mixin', @@ -6,37 +6,44 @@ const SorterMixin = { attributes: { orderBy: { type: String, - default: null + default: null, }, orderAsc: { type: String, - default: null + default: null, }, orderDesc: { type: String, - default: null + default: null, }, orderByRandom: { type: String, - default: null + default: null, }, sortedBy: { - type:String, + type: String, default: null, callback(newValue: string) { // if we change search form, re-populate - if (newValue && this.sortForm && newValue !== this.sortForm.getAttribute('id')) { + if ( + newValue && + this.sortForm && + newValue !== this.sortForm.getAttribute('id') + ) { this.sortForm = null; this.populate(); } - } - } + }, + }, }, initialState: { - randomOrder: null + randomOrder: null, }, attached(): void { - this.listPostProcessors.attach(this.orderCallback.bind(this), 'SorterMixin:orderCallback'); + this.listPostProcessors.attach( + this.orderCallback.bind(this), + 'SorterMixin:orderCallback', + ); }, created(): void { this.randomOrder = []; @@ -52,7 +59,12 @@ const SorterMixin = { }); }, - async orderCallback(resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string) { + async orderCallback( + resources: object[], + listPostProcessors: PostProcessorRegistry, + div: HTMLElement, + context: string, + ) { if (this.orderBy) this.orderAsc = this.orderBy; // retrocompatibility. remove in 0.15 let sortingKey = ''; let orderValueToSort = ''; @@ -67,28 +79,33 @@ const SorterMixin = { if (sortedBy != null) { if (!this.sortForm) { this.sortForm = document.getElementById(sortedBy); - if (!this.sortForm) throw `#${sortedBy} is not in DOM`; + if (!this.sortForm) throw `#${sortedBy} is not in DOM`; this.linkSorterForm(); } if (!this.sortForm.component.value.field) { - console.warn('The attribute field does not exist') - } else { + console.warn('The attribute field does not exist'); + } else { sortingKey = this.sortForm.component.value.field['value']; } const orderField = this.sortForm.component.value.order; - orderValueToSort = orderField && orderField.value ? orderField.value : 'asc'; + orderValueToSort = + orderField && orderField.value ? orderField.value : 'asc'; } } // sorting data according to the defined value of sortingKey if (sortingKey) { let orderToSort = true; // set 'asc' by default - if (this.orderDesc || orderValueToSort == "desc") orderToSort = false; - resources = (await Promise.all(resources.map(async (resource) => ({ - sortingKey: await resource[sortingKey], // fetch sorting value - proxy: resource // and keep proxy - })))) - .sort(this.sortValuesByKey("sortingKey", orderToSort)) // sort this array - .map(r => r.proxy) // re-create array + if (this.orderDesc || orderValueToSort == 'desc') orderToSort = false; + resources = ( + await Promise.all( + resources.map(async resource => ({ + sortingKey: await resource[sortingKey], // fetch sorting value + proxy: resource, // and keep proxy + })), + ) + ) + .sort(this.sortValuesByKey('sortingKey', orderToSort)) // sort this array + .map(r => r.proxy); // re-create array } // if order-by-random attribute else if (this.isRandomSorted()) { @@ -96,7 +113,8 @@ const SorterMixin = { } const nextProcessor = listPostProcessors.shift(); - if(nextProcessor) await nextProcessor(resources, listPostProcessors, div, context); + if (nextProcessor) + await nextProcessor(resources, listPostProcessors, div, context); }, isRandomSorted(): boolean { return this.orderByRandom !== null; @@ -111,21 +129,24 @@ const SorterMixin = { let comparison = 0; if (typeof varA === 'string' && typeof varB === 'string') { - comparison = varA.localeCompare(varB, undefined, { sensitivity: 'base' }); + comparison = varA.localeCompare(varB, undefined, { + sensitivity: 'base', + }); comparison = asc ? comparison : -comparison; } else { if (varA > varB) comparison = asc ? 1 : -1; else if (varA < varB) comparison = asc ? -1 : 1; } return comparison; - } + }; }, shuffleResources(array: object[]): object[] { let currentIndex = array.length; let temporaryValue: object; let randomIndex: number; - if (this.randomOrder.length !== array.length) { // if no random order existing - this.randomOrder = [ ...Array(array.length).keys() ]; // generate array of indexes + if (this.randomOrder.length !== array.length) { + // if no random order existing + this.randomOrder = [...Array(array.length).keys()]; // generate array of indexes while (0 !== currentIndex) { randomIndex = Math.floor(Math.random() * currentIndex); currentIndex -= 1; @@ -135,9 +156,7 @@ const SorterMixin = { } } return this.randomOrder.map((i: number) => array[i]); // rebuild array with random order - } -} + }, +}; -export { - SorterMixin -} \ No newline at end of file +export { SorterMixin }; diff --git a/src/mixins/storeMixin.ts b/src/mixins/storeMixin.ts index 6229b3b6..e8d4a871 100644 --- a/src/mixins/storeMixin.ts +++ b/src/mixins/storeMixin.ts @@ -1,5 +1,8 @@ import { store } from '../libs/store/store'; -import { formatAttributesToServerSearchOptions, mergeServerSearchOptions } from '../libs/store/server-search'; +import { + formatAttributesToServerSearchOptions, + mergeServerSearchOptions, +} from '../libs/store/server-search'; import { AttributeBinderMixin } from './attributeBinderMixin'; import type { Resource } from './interfaces'; import { ContextMixin } from './contextMixin'; @@ -15,40 +18,45 @@ const StoreMixin = { default: null, callback: function (value: boolean) { if (value === null) this.fetchData(this.dataSrc); - } + }, }, dataSrc: { type: String, default: null, callback: async function (value: string) { - const filteredOnServer = this.element.attributes['filtered-on']?.value === 'server'; + const filteredOnServer = + this.element.attributes['filtered-on']?.value === 'server'; const limited = this.element.attributes['limit']?.value !== undefined; - + if (this.noRender === null && !filteredOnServer && !limited) { await this.fetchData(value); } else if (this.noRender === null && !filteredOnServer) { - this.resourceId = value + this.resourceId = value; } }, }, loaderId: { type: String, - default: '' + default: '', }, nestedField: { type: String, - default: null + default: null, }, arrayField: { type: String, default: null, callback: function (value: boolean) { - if (value) this.predicateName = store.getExpandedPredicate(this.arrayField, this.context); - } + if (value) + this.predicateName = store.getExpandedPredicate( + this.arrayField, + this.context, + ); + }, }, predicateName: { type: String, - default: null + default: null, }, }, initialState: { @@ -61,12 +69,14 @@ const StoreMixin = { detached() { if (this.subscription) PubSub.unsubscribe(this.subscription); }, - get resource(): Resource|null{ + get resource(): Resource | null { let id = this.resourceId; - const serverPagination = formatAttributesToServerPaginationOptions(this.element.attributes) + const serverPagination = formatAttributesToServerPaginationOptions( + this.element.attributes, + ); const serverSearch = mergeServerSearchOptions( formatAttributesToServerSearchOptions(this.element.attributes), - this.getDynamicServerSearch?.() // from `filterMixin` + this.getDynamicServerSearch?.(), // from `filterMixin` ); return id ? store.get(id, serverPagination, serverSearch) : null; @@ -77,7 +87,7 @@ const StoreMixin = { async fetchData(value: string) { this.empty(); if (this.subscription) PubSub.unsubscribe(this.subscription); - if (!value || value == "undefined") return; + if (!value || value == 'undefined') return; this.resourceId = value; if (this.nestedField) { @@ -99,15 +109,28 @@ const StoreMixin = { this.updateNavigateSubscription(); - this.subscription = PubSub.subscribe(this.resourceId, this.updateDOM.bind(this)); - const serverPagination = formatAttributesToServerPaginationOptions(this.element.attributes); + this.subscription = PubSub.subscribe( + this.resourceId, + this.updateDOM.bind(this), + ); + const serverPagination = formatAttributesToServerPaginationOptions( + this.element.attributes, + ); const dynamicServerSearch = this.getDynamicServerSearch?.(); // from `filterMixin` const serverSearch = mergeServerSearchOptions( formatAttributesToServerSearchOptions(this.element.attributes), - dynamicServerSearch + dynamicServerSearch, ); const forceRefetch = !!dynamicServerSearch; - await store.getData(this.resourceId, this.context, undefined, undefined, forceRefetch, serverPagination, serverSearch); + await store.getData( + this.resourceId, + this.context, + undefined, + undefined, + forceRefetch, + serverPagination, + serverSearch, + ); this.updateDOM(); }, @@ -115,24 +138,26 @@ const StoreMixin = { toggleLoaderHidden(toggle: boolean): void { if (this.loader) this.loader.toggleAttribute('hidden', toggle); }, - updateNavigateSubscription() { }, + updateNavigateSubscription() {}, async updateDOM(): Promise<void> { this.toggleLoaderHidden(false); // brings a loader out if the attribute is set this.empty(); await this.replaceAttributesData(); await this.populate(); - setTimeout(() => ( // Brings the dispatchEvent at the end of the queue - this.element.dispatchEvent(new CustomEvent('populate', { detail: { resource: {"@id": this.dataSrc} } }))) + setTimeout(() => + // Brings the dispatchEvent at the end of the queue + this.element.dispatchEvent( + new CustomEvent('populate', { + detail: { resource: { '@id': this.dataSrc } }, + }), + ), ); this.toggleLoaderHidden(true); }, - empty():void { - }, + empty(): void {}, update() { if (this.noRender === null) this.updateDOM(); - } + }, }; -export { - StoreMixin -} \ No newline at end of file +export { StoreMixin }; diff --git a/src/mixins/translationMixin.ts b/src/mixins/translationMixin.ts index c23c1706..55223a41 100644 --- a/src/mixins/translationMixin.ts +++ b/src/mixins/translationMixin.ts @@ -1,10 +1,10 @@ -import { store } from "../libs/store/store"; +import { store } from '../libs/store/store'; const TranslationMixin = { name: 'translation-mixin', use: [], initialState: { - translationData:{} + translationData: {}, }, created() { this.getLang(); @@ -15,12 +15,16 @@ const TranslationMixin = { * @returns - object: {key: translation} */ async getTranslationModule(langCode: string) { - const translationsModules = { // define modules in a static way, snowpack does not support dynamic strings here + const translationsModules = { + // define modules in a static way, snowpack does not support dynamic strings here en: () => import('../locales/en.json'), fr: () => import('../locales/fr.json'), }; - if (!translationsModules[langCode]) { // set default to EN if the file does not exist - console.warn(`${langCode}.json translation file may not exist, English is setted by default`); + if (!translationsModules[langCode]) { + // set default to EN if the file does not exist + console.warn( + `${langCode}.json translation file may not exist, English is setted by default`, + ); langCode = 'en'; } const module = await translationsModules[langCode](); @@ -31,16 +35,18 @@ const TranslationMixin = { */ getLang() { const languageStorage = store._getLanguage(); - if(languageStorage) { - if (window.fetchTranslationPromise === undefined) { // if translation data are not already fetched - window.fetchTranslationPromise = this.getTranslationModule(languageStorage); + if (languageStorage) { + if (window.fetchTranslationPromise === undefined) { + // if translation data are not already fetched + window.fetchTranslationPromise = + this.getTranslationModule(languageStorage); } window.fetchTranslationPromise.then(res => { if (res) { this.translationData = res; // stock data in object passed to traduction method below this.update(); // update the rendering in components and widgets } - }) + }); } }, /** @@ -50,9 +56,7 @@ const TranslationMixin = { */ t(tradKey: string) { return this.translationData[tradKey] || ''; - } -} + }, +}; -export { - TranslationMixin -} \ No newline at end of file +export { TranslationMixin }; diff --git a/src/mixins/validationMixin.ts b/src/mixins/validationMixin.ts index 9a5fa2ec..ee3477bd 100644 --- a/src/mixins/validationMixin.ts +++ b/src/mixins/validationMixin.ts @@ -1,4 +1,4 @@ -import dialogPolyfill from 'dialog-polyfill' +import dialogPolyfill from 'dialog-polyfill'; import { html } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; import { uniqID } from '../libs/helpers'; @@ -11,32 +11,32 @@ const ValidationMixin = { attributes: { confirmationMessage: { type: String, - default: null + default: null, }, confirmationType: { type: String, - default: null + default: null, }, confirmationSubmitText: { type: String, - default: null + default: null, }, confirmationCancelText: { type: String, - default: null + default: null, }, confirmationSubmitClass: { type: String, - default: undefined + default: undefined, }, confirmationCancelClass: { type: String, - default: undefined + default: undefined, }, confirmationWidget: { type: String, - default: undefined - } + default: undefined, + }, }, created() { this.dialogID = uniqID(); @@ -48,11 +48,20 @@ const ValidationMixin = { }, performAction() { // Console warning if conf-type attr not filled AND conf-message filled - if (this.element.hasAttribute('confirmation-message') && !this.confirmationType) console.warn('confirmation-type attribute is missing.'); + if ( + this.element.hasAttribute('confirmation-message') && + !this.confirmationType + ) + console.warn('confirmation-type attribute is missing.'); // Data directly submitted OR confirm dialog modal displayed - if ((!this.confirmationType) || (this.confirmationType == "confirm" && confirm(this.confirmationMessage || this.t("validation.message")))) this.validateModal(); + if ( + !this.confirmationType || + (this.confirmationType == 'confirm' && + confirm(this.confirmationMessage || this.t('validation.message'))) + ) + this.validateModal(); // Customisable dialog modal opened - if (this.confirmationType == "dialog") { + if (this.confirmationType == 'dialog') { this.showModal(); } }, @@ -62,35 +71,36 @@ const ValidationMixin = { var dialog: any = document.getElementById(this.dialogID); if (dialog == null) return; dialog.close(); - } + }; const confirmChoice = () => { this.validateModal(); quitDialog(); - } + }; return html` <dialog id="${this.dialogID}"> - ${this.confirmationWidget ? preHTML`<${this.confirmationWidget} value=${this.resourceId}></${this.confirmationWidget}>` : - html`<p>${this.confirmationMessage || this.t("validation.message")}</p>`} + ${ + this.confirmationWidget + ? preHTML`<${this.confirmationWidget} value=${this.resourceId}></${this.confirmationWidget}>` + : html`<p>${this.confirmationMessage || this.t('validation.message')}</p>` + } <div> <button @click=${confirmChoice} class=${ifDefined(this.confirmationSubmitClass)} > - ${this.confirmationSubmitText || this.t("validation.submit-text")} + ${this.confirmationSubmitText || this.t('validation.submit-text')} </button> <button @click=${quitDialog} class=${ifDefined(this.confirmationCancelClass)} > - ${this.confirmationCancelText || this.t("validation.cancel-text")} + ${this.confirmationCancelText || this.t('validation.cancel-text')} </button> </div> </dialog> - ` + `; } else return ''; }, -} +}; -export { - ValidationMixin -} \ No newline at end of file +export { ValidationMixin }; diff --git a/src/mixins/widgetMixin.ts b/src/mixins/widgetMixin.ts index 858be17d..bfd513ec 100644 --- a/src/mixins/widgetMixin.ts +++ b/src/mixins/widgetMixin.ts @@ -1,5 +1,8 @@ import { spread, preHTML } from '../libs/lit-helpers'; -import { parseFieldsString, findClosingBracketMatchIndex } from '../libs/helpers'; +import { + parseFieldsString, + findClosingBracketMatchIndex, +} from '../libs/helpers'; import { newWidgetFactory } from '../new-widgets/new-widget-factory'; import { WidgetInterface, WidgetType, Resource } from './interfaces'; import { html, render, TemplateResult } from 'lit'; @@ -12,17 +15,18 @@ const WidgetMixin = { fields: { type: String, default: undefined, - } + }, }, initialState: { nameWidgets: null, - _div: null + _div: null, }, created(): void { this.nameWidgets = []; }, attached(): void { - if (!this.dataSrc && !this.resource && this.noRender === null) this.populate(); + if (!this.dataSrc && !this.resource && this.noRender === null) + this.populate(); }, get parentElement(): string { return 'div'; @@ -34,39 +38,45 @@ const WidgetMixin = { return this._div; }, set div(value) { - this._div = value + this._div = value; }, get widgets() { - return this.nameWidgets.map((name: string) => this.element.querySelector(`[name="${name}"]`)); + return this.nameWidgets.map((name: string) => + this.element.querySelector(`[name="${name}"]`), + ); }, /** * Return field list of the component */ - async getFields(): Promise<string[]>{ // TODO : improve code + async getFields(): Promise<string[]> { + // TODO : improve code const attr = this.fields; if (attr === '') return []; if (attr) return parseFieldsString(attr); let resource = this.resource as Resource; - if (resource && resource.isContainer?.()) { // If container, keep the 1rst resource + if (resource && resource.isContainer?.()) { + // If container, keep the 1rst resource for (let res of resource['ldp:contains']) { resource = res; break; } - } else if (resource && this.arrayField && this.predicateName) { // if array, keep the 1rst resource + } else if (resource && this.arrayField && this.predicateName) { + // if array, keep the 1rst resource for (let res of resource[this.predicateName]) { resource = res; break; } } - if (!this.dataSrc) console.error(new Error('You must provide a "fields" attribute')); - if(!resource) return []; + if (!this.dataSrc) + console.error(new Error('You must provide a "fields" attribute')); + if (!resource) return []; let fields: string[] = []; for (const prop of resource.properties) { - if ((!prop.startsWith('@') && !(prop === "permissions"))) { - if (!this.isAlias(prop) && await resource[prop]) fields.push(prop); + if (!prop.startsWith('@') && !(prop === 'permissions')) { + if (!this.isAlias(prop) && (await resource[prop])) fields.push(prop); else if (this.isAlias(prop)) fields.push(prop); } } @@ -92,7 +102,7 @@ const WidgetMixin = { * @param field - string */ getSetRegexp(field: string) { - return new RegExp(`(^|\\,|\\(|\\s)\\s*${field}\\s*\\(`, 'g') + return new RegExp(`(^|\\,|\\(|\\s)\\s*${field}\\s*\\(`, 'g'); }, /** * Return fields contained in set "field" @@ -101,8 +111,12 @@ const WidgetMixin = { getSet(field: string): string[] { const setString = this.fields.match(this.getSetRegexp(field)); if (!setString) return []; - const firstSetBracket = this.fields.indexOf(setString[0]) + (setString[0].length) - 1; - const lastSetBracket = findClosingBracketMatchIndex(this.fields, firstSetBracket); + const firstSetBracket = + this.fields.indexOf(setString[0]) + setString[0].length - 1; + const lastSetBracket = findClosingBracketMatchIndex( + this.fields, + firstSetBracket, + ); const set = this.fields.substring(firstSetBracket + 1, lastSetBracket); return parseFieldsString(set); }, @@ -120,7 +134,7 @@ const WidgetMixin = { * @param field - string */ isString(field: string): boolean { - return field.startsWith('\'') || field.startsWith('\"'); + return field.startsWith("'") || field.startsWith('"'); }, /** * Return true if "field" is an alias (contains " as ") @@ -138,22 +152,34 @@ const WidgetMixin = { async fetchValue(field: string, resource: Resource) { if (resource && !resource.isContainer?.()) { let fieldValue = await resource[field]; - if (fieldValue === null || fieldValue === undefined || fieldValue === '') { - let expandedPredicate = sibStore.getExpandedPredicate(field, this.context); + if ( + fieldValue === null || + fieldValue === undefined || + fieldValue === '' + ) { + let expandedPredicate = sibStore.getExpandedPredicate( + field, + this.context, + ); fieldValue = await resource[expandedPredicate]; } - if (fieldValue === null || fieldValue === undefined || fieldValue === '') return undefined; + if (fieldValue === null || fieldValue === undefined || fieldValue === '') + return undefined; if (Array.isArray(fieldValue) && !fieldValue['ldp:contains']) { return JSON.stringify(fieldValue); - // Dumb edge case because if the array bears only one item, when compacted the array translates into one object + // Dumb edge case because if the array bears only one item, when compacted the array translates into one object } else if ( typeof fieldValue === 'object' && - fieldValue['@id'] && 1 === Object.keys(fieldValue).length) { + fieldValue['@id'] && + 1 === Object.keys(fieldValue).length + ) { return JSON.stringify([fieldValue]); } } - return resource && !resource.isContainer?.() ? await resource[field] : undefined; + return resource && !resource.isContainer?.() + ? await resource[field] + : undefined; }, /** * Return the value of the field @@ -176,9 +202,15 @@ const WidgetMixin = { let resourceValue = await this.fetchValue(field, resource); // Empty value - if (resourceValue === undefined || resourceValue === '' || resourceValue === null) // If null or empty, return field default value - return this.element.hasAttribute('default-' + field) ? - this.element.getAttribute('default-' + field) : ''; + if ( + resourceValue === undefined || + resourceValue === '' || + resourceValue === null + ) + // If null or empty, return field default value + return this.element.hasAttribute('default-' + field) + ? this.element.getAttribute('default-' + field) + : ''; return resourceValue; }, @@ -188,9 +220,13 @@ const WidgetMixin = { * @param tagName - string */ widgetFromTagName(tagName: string) { - let type = tagName.startsWith('solid') ? WidgetType.CUSTOM : WidgetType.USER; - if (!customElements.get(tagName)) { // component does not exist - if (tagName.startsWith('solid')) newWidgetFactory(tagName); // solid- -> create it + let type = tagName.startsWith('solid') + ? WidgetType.CUSTOM + : WidgetType.USER; + if (!customElements.get(tagName)) { + // component does not exist + if (tagName.startsWith('solid')) + newWidgetFactory(tagName); // solid- -> create it else type = WidgetType.NATIVE; // or use a native tag } return { tagName, type }; // return tagName @@ -207,16 +243,19 @@ const WidgetMixin = { if (widget) return this.widgetFromTagName(widget); if (this.getAction(field)) return this.widgetFromTagName('solid-action'); - return !isSet ? this.widgetFromTagName(this.defaultWidget) : this.widgetFromTagName(this.defaultSetWidget); + return !isSet + ? this.widgetFromTagName(this.defaultWidget) + : this.widgetFromTagName(this.defaultSetWidget); }, /** * Return multiple widget if "field" is a multiple, false if it's not * @param field - string */ - multiple(field: string): WidgetInterface|null { + multiple(field: string): WidgetInterface | null { const attribute = 'multiple-' + field; if (!this.element.hasAttribute(attribute)) return null; - const widget = this.element.getAttribute(attribute) || this.defaultMultipleWidget; + const widget = + this.element.getAttribute(attribute) || this.defaultMultipleWidget; return this.widgetFromTagName(widget); }, /** @@ -247,12 +286,13 @@ const WidgetMixin = { 'widget', 'add-label', 'remove-label', - 'next', + 'next', 'empty-widget', 'add-class', - 'remove-class' + 'remove-class', ]; - for (let attr of multipleAttributes) this.addToAttributes(`multiple-${escapedField}-${attr}`, attr, attrs) + for (let attr of multipleAttributes) + this.addToAttributes(`multiple-${escapedField}-${attr}`, attr, attrs); // transfer all [attr]-[field] attributes as [attr] attribute for widget [field] const defaultAttributes = [ @@ -261,8 +301,8 @@ const WidgetMixin = { 'label', 'placeholder', 'class', - /* 'widget', */, - 'required', + , + /* 'widget', */ 'required', 'editable', 'autocomplete', 'upload-url', @@ -286,47 +326,70 @@ const WidgetMixin = { 'search-placeholder', 'link-text', 'target-src', - 'data-label' + 'data-label', ]; - for (let attr of defaultAttributes) this.addToAttributes(`${attr}-${escapedField}`, attr, attrs) + for (let attr of defaultAttributes) + this.addToAttributes(`${attr}-${escapedField}`, attr, attrs); - const addableAttributes: Attr[] = (Array.from(this.element.attributes) as Attr[]).filter((a: Attr) => a.name.startsWith(`addable-${escapedField}`)); - for (let attr of addableAttributes) this.addToAttributes(attr.name, attr.name.replace(`addable-${escapedField}`, 'addable'), attrs) + const addableAttributes: Attr[] = ( + Array.from(this.element.attributes) as Attr[] + ).filter((a: Attr) => a.name.startsWith(`addable-${escapedField}`)); + for (let attr of addableAttributes) + this.addToAttributes( + attr.name, + attr.name.replace(`addable-${escapedField}`, 'addable'), + attrs, + ); const resourceId = resource ? resource!['@id'] : null; - if (this.multiple(escapedField)) attrs['widget'] = this.getWidget(escapedField).tagName; - if (this.getAction(escapedField) && resourceId) attrs['src'] = this.element.getAttribute('src-' + escapedField) || resourceId; - if (this.editable(escapedField) && resourceId) attrs['value-id'] = resourceId; + if (this.multiple(escapedField)) + attrs['widget'] = this.getWidget(escapedField).tagName; + if (this.getAction(escapedField) && resourceId) + attrs['src'] = + this.element.getAttribute('src-' + escapedField) || resourceId; + if (this.editable(escapedField) && resourceId) + attrs['value-id'] = resourceId; return attrs; }, /** * Creates and return a widget for field + add it to the widget list * @param field - string */ - async createWidgetTemplate(field: string, resource = null, transformAttributes = false): Promise<TemplateResult> { + async createWidgetTemplate( + field: string, + resource = null, + transformAttributes = false, + ): Promise<TemplateResult> { if (this.isString(field)) return this.createString(field); // field is a static string if (this.isSet(field)) return await this.createSet(field); const currentResource = resource || this.resource; let attributes = this.widgetAttributes(field, currentResource); const escapedField = this.getEscapedField(field); - const widgetMeta = this.multiple(escapedField) || this.getWidget(escapedField); + const widgetMeta = + this.multiple(escapedField) || this.getWidget(escapedField); let tagName = widgetMeta.tagName; let widgetTemplate: TemplateResult = html``; // Set attributes let value = await this.getValue(field, currentResource); - if (widgetMeta.type === WidgetType.NATIVE) { // native widget (ie: h1) + if (widgetMeta.type === WidgetType.NATIVE) { + // native widget (ie: h1) widgetTemplate = preHTML`<${tagName} name="${ifDefined(attributes.name)}" class="${ifDefined(attributes.class)}">${value}</${tagName}>`; - } else { // custom widget (ie: solid-display-value) + } else { + // custom widget (ie: solid-display-value) // Check if value is defined, and if the default widget is needed - if ((value === null || value === '') && this.element.hasAttribute('default-widget-' + field)) { + if ( + (value === null || value === '') && + this.element.hasAttribute('default-widget-' + field) + ) { tagName = this.element.getAttribute('default-widget-' + field); } // Set attributes to the widget // setAttribute set a string. Make sure null values are empty if (value === null || value === undefined) attributes.value = ''; - if (widgetMeta.type === WidgetType.USER) { // if value is a resource and solid-widget used, set data-src + if (widgetMeta.type === WidgetType.USER) { + // if value is a resource and solid-widget used, set data-src if (value['@id']) { attributes['data-src'] = value['@id']; } else { @@ -338,7 +401,8 @@ const WidgetMixin = { // in any case, set value attribute attributes['value'] = value; } - } else { // otherwise, set value attribute + } else { + // otherwise, set value attribute attributes['value'] = value; } @@ -346,7 +410,11 @@ const WidgetMixin = { if (value && value['@id']) attributes['auto-subscribe'] = value['@id']; // Transform store://XXX attributes - if (transformAttributes) attributes = await this.transformAttributes(attributes, currentResource); + if (transformAttributes) + attributes = await this.transformAttributes( + attributes, + currentResource, + ); widgetTemplate = preHTML`<${tagName} ...=${spread(attributes)}></${tagName}>`; } @@ -355,7 +423,8 @@ const WidgetMixin = { return widgetTemplate; }, defineAttribute(widget: HTMLElement, attribute: string, value: any) { - if (widget.getAttribute(attribute) !== value) { // if attribute is different than previous one + if (widget.getAttribute(attribute) !== value) { + // if attribute is different than previous one widget.setAttribute(attribute, value); // set it } }, @@ -368,14 +437,14 @@ const WidgetMixin = { // Get set attributes const attrs = { name: field }; - const setAttributes = [ - 'class', - 'label' - ]; - for (let attr of setAttributes) this.addToAttributes(`${attr}-${field}`, attr, attrs); + const setAttributes = ['class', 'label']; + for (let attr of setAttributes) + this.addToAttributes(`${attr}-${field}`, attr, attrs); // Create widget if not already existing - let widget = this.element.querySelector(`${setWidget.tagName}[name="${field}"]`); + let widget = this.element.querySelector( + `${setWidget.tagName}[name="${field}"]`, + ); let initializing = false; // used to render widget only first time if (!widget) { widget = document.createElement(setWidget.tagName); @@ -389,24 +458,28 @@ const WidgetMixin = { // Catch widget for the set if all these fields are empty if (this.element.hasAttribute('empty-' + field)) { let hasOnlyEmpty = true; - for(let field of setFields) { + for (let field of setFields) { let value: string = await this.getValue(field, this.resource); - if (value !== '') { // if one not empty + if (value !== '') { + // if one not empty hasOnlyEmpty = false; continue; // break loop } - }; - if(hasOnlyEmpty) { // if only empty values, return empty-widget + } + if (hasOnlyEmpty) { + // if only empty values, return empty-widget const attributes = this.widgetAttributes(field, this.resource); const tagName = this.element.getAttribute(`empty-${field}`); const valueSet = this.element.getAttribute(`empty-${field}-value`); if (valueSet) attributes.value = valueSet; return preHTML`<${tagName} ...=${spread(attributes)}></${tagName}>`; - }; + } } // Render template - const widgetsTemplate = await Promise.all(setFields.map((field: string) => this.createWidgetTemplate(field))); + const widgetsTemplate = await Promise.all( + setFields.map((field: string) => this.createWidgetTemplate(field)), + ); const template = html`${widgetsTemplate}`; render(template, widget.querySelector('[data-content]') || widget); return widget; @@ -420,9 +493,7 @@ const WidgetMixin = { */ getEscapedField(field: string): string { return field.startsWith('@') ? field.slice(1, field.length) : field; - } -} + }, +}; -export { - WidgetMixin -} \ No newline at end of file +export { WidgetMixin }; diff --git a/src/new-widgets/attributeMixins/actionMixin.ts b/src/new-widgets/attributeMixins/actionMixin.ts index a50058cd..6a5e25f4 100644 --- a/src/new-widgets/attributeMixins/actionMixin.ts +++ b/src/new-widgets/attributeMixins/actionMixin.ts @@ -6,18 +6,16 @@ const ActionMixin = { default: '', callback: function (newValue: string) { this.addToAttributes(newValue, 'src'); - } + }, }, targetSrc: { type: String, default: '', callback: function (newValue: string) { this.addToAttributes(newValue, 'target-src'); - } + }, }, }, -} +}; -export { - ActionMixin -} \ No newline at end of file +export { ActionMixin }; diff --git a/src/new-widgets/attributeMixins/blankMixin.ts b/src/new-widgets/attributeMixins/blankMixin.ts index 0ecac831..b310e86d 100644 --- a/src/new-widgets/attributeMixins/blankMixin.ts +++ b/src/new-widgets/attributeMixins/blankMixin.ts @@ -2,9 +2,7 @@ const BlankMixin = { name: 'blank-mixin', created() { this.listAttributes['target'] = '_blank'; - } -} + }, +}; -export { - BlankMixin -} \ No newline at end of file +export { BlankMixin }; diff --git a/src/new-widgets/attributeMixins/index.ts b/src/new-widgets/attributeMixins/index.ts index 0106ad77..9070a645 100644 --- a/src/new-widgets/attributeMixins/index.ts +++ b/src/new-widgets/attributeMixins/index.ts @@ -16,7 +16,7 @@ const attributeDirectory = { placeholder: PlaceholderMixin, bool: BooleanMixin, num: NumberMixin, -} +}; export { attributeDirectory, @@ -26,4 +26,4 @@ export { MailtoMixin, TelMixin, PlaceholderMixin, -} +}; diff --git a/src/new-widgets/attributeMixins/mailtoMixin.ts b/src/new-widgets/attributeMixins/mailtoMixin.ts index 618264e4..0a8471f0 100644 --- a/src/new-widgets/attributeMixins/mailtoMixin.ts +++ b/src/new-widgets/attributeMixins/mailtoMixin.ts @@ -2,9 +2,7 @@ const MailtoMixin = { name: 'mailto-mixin', created() { this.listAttributes['mailto'] = 'mailto:'; - } -} + }, +}; -export { - MailtoMixin -} \ No newline at end of file +export { MailtoMixin }; diff --git a/src/new-widgets/attributeMixins/multipleMixin.ts b/src/new-widgets/attributeMixins/multipleMixin.ts index 90e0e01f..45bab1ea 100644 --- a/src/new-widgets/attributeMixins/multipleMixin.ts +++ b/src/new-widgets/attributeMixins/multipleMixin.ts @@ -6,25 +6,23 @@ const MultipleMixin = { default: '', callback: function (newValue: string) { this.addToAttributes(newValue, 'fields'); - } + }, }, next: { type: String, default: '', callback: function (newValue: string) { this.addToAttributes(newValue, 'next'); - } + }, }, emptyWidget: { type: String, default: '', callback: function (newValue: string) { this.addToAttributes(newValue, 'emptyWidget'); - } - } + }, + }, }, -} +}; -export { - MultipleMixin -} \ No newline at end of file +export { MultipleMixin }; diff --git a/src/new-widgets/attributeMixins/placeholderMixin.ts b/src/new-widgets/attributeMixins/placeholderMixin.ts index 301bcb70..54446fca 100644 --- a/src/new-widgets/attributeMixins/placeholderMixin.ts +++ b/src/new-widgets/attributeMixins/placeholderMixin.ts @@ -6,14 +6,13 @@ const PlaceholderMixin = { default: '', callback: function (newValue: string) { this.addToAttributes(newValue, 'placeholder'); - } + }, }, }, attached() { - this.listAttributes['placeholder'] = this.placeholder || this.label || this.name || ''; - } -} + this.listAttributes['placeholder'] = + this.placeholder || this.label || this.name || ''; + }, +}; -export { - PlaceholderMixin -} \ No newline at end of file +export { PlaceholderMixin }; diff --git a/src/new-widgets/attributeMixins/telMixin.ts b/src/new-widgets/attributeMixins/telMixin.ts index 26a9a1e0..5d1530f8 100644 --- a/src/new-widgets/attributeMixins/telMixin.ts +++ b/src/new-widgets/attributeMixins/telMixin.ts @@ -2,9 +2,7 @@ const TelMixin = { name: 'tel-mixin', created() { this.listAttributes['tel'] = 'tel:'; - } -} + }, +}; -export { - TelMixin -} \ No newline at end of file +export { TelMixin }; diff --git a/src/new-widgets/baseWidgetMixin.ts b/src/new-widgets/baseWidgetMixin.ts index eea880ef..8f2b04d1 100644 --- a/src/new-widgets/baseWidgetMixin.ts +++ b/src/new-widgets/baseWidgetMixin.ts @@ -1,7 +1,7 @@ import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; import type { Template } from './interfaces'; -import {render} from 'lit'; +import { render } from 'lit'; const BaseWidgetMixin = { name: 'widget-mixin', @@ -12,21 +12,21 @@ const BaseWidgetMixin = { default: '', callback: function () { this.planRender(); - } + }, }, name: { type: String, default: '', callback: function (newValue: string) { this.addToAttributes(newValue, 'name'); - } + }, }, label: { type: String, default: null, callback: function (newValue: string) { this.addToAttributes(newValue, 'label'); - } + }, }, autoSubscribe: { type: String, @@ -34,7 +34,7 @@ const BaseWidgetMixin = { callback: function (newValue: string) { if (this.subscription) PubSub.unsubscribe(this.subscription); this.subscribe(newValue); - } + }, }, }, initialState: { @@ -45,7 +45,7 @@ const BaseWidgetMixin = { renderPlanned: false, }, get template() { - return null + return null; }, created() { this.listValueTransformations = new PostProcessorRegistry(); @@ -70,8 +70,12 @@ const BaseWidgetMixin = { } }, render() { - const listValueTransformationsCopy = this.listValueTransformations.deepCopy(); - listValueTransformationsCopy.attach(this.renderTemplate.bind(this), "BaseWidgetMixin:renderTemplate"); + const listValueTransformationsCopy = + this.listValueTransformations.deepCopy(); + listValueTransformationsCopy.attach( + this.renderTemplate.bind(this), + 'BaseWidgetMixin:renderTemplate', + ); const nextProcessor = listValueTransformationsCopy.shift(); nextProcessor(this.value, listValueTransformationsCopy); @@ -82,12 +86,17 @@ const BaseWidgetMixin = { nextCallback(this.value, listCallbacksCopy); } - this.element.dispatchEvent(new CustomEvent('widgetRendered', { bubbles: true })); + this.element.dispatchEvent( + new CustomEvent('widgetRendered', { bubbles: true }), + ); }, renderTemplate(value: string) { const template: Template = this.template(value, { ...this.listAttributes }); const listTemplateAdditionsCopy = this.listTemplateAdditions.deepCopy(); - listTemplateAdditionsCopy.attach(this.templateToDOM.bind(this), "BaseWidgetMixin:templateToDOM"); + listTemplateAdditionsCopy.attach( + this.templateToDOM.bind(this), + 'BaseWidgetMixin:templateToDOM', + ); const nextProcessor = listTemplateAdditionsCopy.shift(); nextProcessor(template, listTemplateAdditionsCopy); @@ -106,9 +115,7 @@ const BaseWidgetMixin = { }, update() { this.planRender(); - } -} + }, +}; -export { - BaseWidgetMixin -} \ No newline at end of file +export { BaseWidgetMixin }; diff --git a/src/new-widgets/callbackMixins/autocompletionMixin.ts b/src/new-widgets/callbackMixins/autocompletionMixin.ts index 29b66cb3..b7a7a7fc 100644 --- a/src/new-widgets/callbackMixins/autocompletionMixin.ts +++ b/src/new-widgets/callbackMixins/autocompletionMixin.ts @@ -1,4 +1,8 @@ -import { asyncQuerySelector, fuzzyCompare, importInlineCSS } from '../../libs/helpers'; +import { + asyncQuerySelector, + fuzzyCompare, + importInlineCSS, +} from '../../libs/helpers'; import SlimSelect from 'slim-select'; import { TranslationMixin } from '../../mixins/translationMixin'; import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; @@ -12,27 +16,36 @@ const AutocompletionMixin = { default: null, callback: function (newValue: string) { this.addToAttributes(newValue, 'searchText'); - } + }, }, searchPlaceholder: { type: String, default: null, callback: function (newValue: string) { this.addToAttributes(newValue, 'searchPlaceholder'); - } + }, }, }, initialState: { slimSelect: null, - mutationObserver: null + mutationObserver: null, }, created() { - importInlineCSS('slimselect-base', () => import('slim-select/styles?inline')); - importInlineCSS('slimselect-local', () => import('./slimselect.css?inline')); + importInlineCSS( + 'slimselect-base', + () => import('slim-select/styles?inline'), + ); + importInlineCSS( + 'slimselect-local', + () => import('./slimselect.css?inline'), + ); this.slimSelect = null; this.addToAttributes(true, 'autocomplete'); - this.listCallbacks.attach(this.addCallback.bind(this), "AutocompletionMixin:addCallback"); + this.listCallbacks.attach( + this.addCallback.bind(this), + 'AutocompletionMixin:addCallback', + ); }, detached() { if (this.slimSelect) this.slimSelect.destroy(); @@ -42,27 +55,30 @@ const AutocompletionMixin = { if (this.slimSelect) return; asyncQuerySelector('select:has(option)', this.element).then(select => { this.initSlimSelect(select); - }) + }); const nextProcessor = listCallbacks.shift(); if (nextProcessor) nextProcessor(value, listCallbacks); }, async initSlimSelect(select: Element) { - await new Promise(resolve => setTimeout(resolve, 500)) + await new Promise(resolve => setTimeout(resolve, 500)); const slimSelect = new SlimSelect({ select, settings: { - placeholderText: this.placeholder || this.t("autocompletion.placeholder"), - searchText: this.searchText || this.t("autocompletion.searchText"), - searchPlaceholder: this.searchPlaceholder || this.t("autocompletion.searchPlaceholder"), + placeholderText: + this.placeholder || this.t('autocompletion.placeholder'), + searchText: this.searchText || this.t('autocompletion.searchText'), + searchPlaceholder: + this.searchPlaceholder || this.t('autocompletion.searchPlaceholder'), contentLocation: this.element, }, events: { - searchFilter: (option, filterValue) => fuzzyCompare(option.text, filterValue), + searchFilter: (option, filterValue) => + fuzzyCompare(option.text, filterValue), }, }); this.slimSelect = slimSelect; - this.element.addEventListener('input', (e:Event) => { - if(e.target !== this.element) { + this.element.addEventListener('input', (e: Event) => { + if (e.target !== this.element) { // avoid update search result when search in slimSelect suggestions e.stopPropagation(); } diff --git a/src/new-widgets/callbackMixins/index.ts b/src/new-widgets/callbackMixins/index.ts index eca6ff7a..3f288db3 100644 --- a/src/new-widgets/callbackMixins/index.ts +++ b/src/new-widgets/callbackMixins/index.ts @@ -4,10 +4,6 @@ import { RichtextMixin } from './richtextMixin'; const callbackDirectory = { autocompletion: AutocompletionMixin, richtext: RichtextMixin, -} +}; -export { - callbackDirectory, - AutocompletionMixin, - RichtextMixin, -} +export { callbackDirectory, AutocompletionMixin, RichtextMixin }; diff --git a/src/new-widgets/callbackMixins/richtextMixin.ts b/src/new-widgets/callbackMixins/richtextMixin.ts index 707f91f5..8070a69a 100644 --- a/src/new-widgets/callbackMixins/richtextMixin.ts +++ b/src/new-widgets/callbackMixins/richtextMixin.ts @@ -6,63 +6,71 @@ import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.js'; const RichtextMixin = { name: 'richtext-mixin', - initialState:{ + initialState: { quill: null, }, created() { - importInlineCSS('quill', () => import('quill/dist/quill.snow.css?inline')) - + importInlineCSS('quill', () => import('quill/dist/quill.snow.css?inline')); + this.quill = null; - this.listCallbacks.attach(this.addCallback.bind(this), "RichtextMixin:addCallback"); + this.listCallbacks.attach( + this.addCallback.bind(this), + 'RichtextMixin:addCallback', + ); }, getPlaceHolderValue() { - return this.element.hasAttribute('placeholder') ? this.element.getAttribute('placeholder') : ''; + return this.element.hasAttribute('placeholder') + ? this.element.getAttribute('placeholder') + : ''; }, addCallback(value: string, listCallbacks: PostProcessorRegistry) { if (this.quill == null) { var toolbarOptions = [ ['bold', 'italic'], ['blockquote'], - [{ 'header': [1, 2, 3, 4, 5, 6, false]}], - [{ 'list': 'ordered'}, { 'list': 'bullet' }], + [{ header: [1, 2, 3, 4, 5, 6, false] }], + [{ list: 'ordered' }, { list: 'bullet' }], ['link'], - ['clean'] + ['clean'], ]; - const richtext = this.element.querySelector('[data-richtext]') as HTMLElement; - this.quill = new Quill( - richtext, - { - modules: {toolbar: toolbarOptions}, - placeholder: this.getPlaceHolderValue(), - theme: 'snow' - } - ); + const richtext = this.element.querySelector( + '[data-richtext]', + ) as HTMLElement; + this.quill = new Quill(richtext, { + modules: { toolbar: toolbarOptions }, + placeholder: this.getPlaceHolderValue(), + theme: 'snow', + }); } const ops = deltaMd.toDelta(this.value); this.quill.setContents(ops); if (this.isRequired()) { - this.createHiddenRequiredInput() - this.quill.on('text-change', this.onTextChange.bind(this)) + this.createHiddenRequiredInput(); + this.quill.on('text-change', this.onTextChange.bind(this)); } const nextProcessor = listCallbacks.shift(); - if (nextProcessor) nextProcessor(value, listCallbacks); + if (nextProcessor) nextProcessor(value, listCallbacks); }, isRequired() { - return Array.from(this.element.attributes).some(attr => (attr as Attr).name === 'required') + return Array.from(this.element.attributes).some( + attr => (attr as Attr).name === 'required', + ); }, createHiddenRequiredInput() { const attributeName = this.getAttributeValue('name'); - this.hiddenInput = document.querySelector(`input[name="${attributeName + '-hidden'}"]`) as HTMLInputElement; + this.hiddenInput = document.querySelector( + `input[name="${attributeName + '-hidden'}"]`, + ) as HTMLInputElement; if (!this.hiddenInput) { this.hiddenInput = this.createHiddenInput(attributeName + '-hidden'); this.element.appendChild(this.hiddenInput); this.addInvalidEventListener(); } - this.hiddenInput.value=this.quill.getText(); + this.hiddenInput.value = this.quill.getText(); }, createHiddenInput(attributeName: string): HTMLInputElement { const input = document.createElement('input'); @@ -74,15 +82,19 @@ const RichtextMixin = { return input; }, getAttributeValue(attributeName: string): string { - const attribute = Array.from(this.element.attributes).find(attr => (attr as Attr).name === attributeName) as Attr; + const attribute = Array.from(this.element.attributes).find( + attr => (attr as Attr).name === attributeName, + ) as Attr; return attribute ? attribute.value : ''; }, displayCustomErrorMessage(message: string) { - const richtext = this.element.querySelector('[data-richtext]'); - + const richtext = this.element.querySelector('[data-richtext]'); + if (richtext) { - let errorMessageElement = richtext.querySelector('.required-error-message') as HTMLDivElement; - + let errorMessageElement = richtext.querySelector( + '.required-error-message', + ) as HTMLDivElement; + if (!errorMessageElement) { errorMessageElement = document.createElement('div'); errorMessageElement.className = 'required-error-message'; @@ -94,25 +106,24 @@ const RichtextMixin = { } }, addInvalidEventListener() { - this.hiddenInput.addEventListener("invalid", (e) => { + this.hiddenInput.addEventListener('invalid', e => { e.preventDefault(); this.displayCustomErrorMessage('Please fill out this field.'); }); }, onTextChange() { - this.hiddenInput.value=this.quill.getText(); + this.hiddenInput.value = this.quill.getText(); this.removeErrorMessageAndStyling(); }, removeErrorMessageAndStyling() { // Remove any previously displayed error message and error styling const richtext = this.element.querySelector('[data-richtext]'); - let errorMessageElement = richtext.querySelector('.required-error-message') as HTMLDivElement; - if (errorMessageElement) - errorMessageElement.remove() + let errorMessageElement = richtext.querySelector( + '.required-error-message', + ) as HTMLDivElement; + if (errorMessageElement) errorMessageElement.remove(); richtext.classList.remove('error-border-richtext'); }, -} +}; -export { - RichtextMixin -} \ No newline at end of file +export { RichtextMixin }; diff --git a/src/new-widgets/callbackMixins/slimselect.css b/src/new-widgets/callbackMixins/slimselect.css index 3a795bad..07a93c53 100644 --- a/src/new-widgets/callbackMixins/slimselect.css +++ b/src/new-widgets/callbackMixins/slimselect.css @@ -1,2 +1,339 @@ -.ss-main{position:relative;display:inline-block;user-select:none;color:#666;width:100%}.ss-main .ss-single-selected{display:flex;cursor:pointer;width:100%;height:30px;padding:6px;border:1px solid #dcdee2;border-radius:4px;background-color:#fff;outline:0;box-sizing:border-box;transition:background-color .2s}.ss-main .ss-single-selected.ss-disabled{background-color:#dcdee2;cursor:not-allowed}.ss-main .ss-single-selected.ss-open-above{border-top-left-radius:0px;border-top-right-radius:0px}.ss-main .ss-single-selected.ss-open-below{border-bottom-left-radius:0px;border-bottom-right-radius:0px}.ss-main .ss-single-selected .placeholder{display:flex;flex:1 1 100%;align-items:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:left;width:calc(100% - 30px);line-height:1em;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.ss-main .ss-single-selected .placeholder *{display:flex;align-items:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:auto}.ss-main .ss-single-selected .placeholder .ss-disabled{color:#dedede}.ss-main .ss-single-selected .ss-deselect{display:flex;align-items:center;justify-content:flex-end;flex:0 1 auto;margin:0 6px 0 6px;font-weight:bold}.ss-main .ss-single-selected .ss-deselect.ss-hide{display:none}.ss-main .ss-single-selected .ss-arrow{display:flex;align-items:center;justify-content:flex-end;flex:0 1 auto;margin:0 6px 0 6px}.ss-main .ss-single-selected .ss-arrow span{border:solid #666;border-width:0 2px 2px 0;display:inline-block;padding:3px;transition:transform .2s, margin .2s}.ss-main .ss-single-selected .ss-arrow span.arrow-up{transform:rotate(-135deg);margin:3px 0 0 0}.ss-main .ss-single-selected .ss-arrow span.arrow-down{transform:rotate(45deg);margin:-3px 0 0 0}.ss-main .ss-multi-selected{display:flex;flex-direction:row;cursor:pointer;min-height:30px;width:100%;padding:0 0 0 3px;border:1px solid #dcdee2;border-radius:4px;background-color:#fff;outline:0;box-sizing:border-box;transition:background-color .2s}.ss-main .ss-multi-selected.ss-disabled{background-color:#dcdee2;cursor:not-allowed}.ss-main .ss-multi-selected.ss-disabled .ss-values .ss-disabled{color:#666}.ss-main .ss-multi-selected.ss-disabled .ss-values .ss-value .ss-value-delete{cursor:not-allowed}.ss-main .ss-multi-selected.ss-open-above{border-top-left-radius:0px;border-top-right-radius:0px}.ss-main .ss-multi-selected.ss-open-below{border-bottom-left-radius:0px;border-bottom-right-radius:0px}.ss-main .ss-multi-selected .ss-values{display:flex;flex-wrap:wrap;justify-content:flex-start;flex:1 1 100%;width:calc(100% - 30px)}.ss-main .ss-multi-selected .ss-values .ss-disabled{display:flex;padding:4px 5px;margin:2px 0px;line-height:1em;align-items:center;width:100%;color:#dedede;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}@keyframes scaleIn{0%{transform:scale(0);opacity:0}100%{transform:scale(1);opacity:1}}@keyframes scaleOut{0%{transform:scale(1);opacity:1}100%{transform:scale(0);opacity:0}}.ss-main .ss-multi-selected .ss-values .ss-value{display:flex;user-select:none;align-items:center;font-size:12px;padding:3px 5px;margin:3px 5px 3px 0px;color:#fff;background-color:#5897fb;border-radius:4px;animation-name:scaleIn;animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:both}.ss-main .ss-multi-selected .ss-values .ss-value.ss-out{animation-name:scaleOut;animation-duration:.2s;animation-timing-function:ease-out}.ss-main .ss-multi-selected .ss-values .ss-value .ss-value-delete{margin:0 0 0 5px;cursor:pointer}.ss-main .ss-multi-selected .ss-add{display:flex;flex:0 1 3px;margin:9px 12px 0 5px}.ss-main .ss-multi-selected .ss-add .ss-plus{display:flex;justify-content:center;align-items:center;background:#666;position:relative;height:10px;width:2px;transition:transform .2s}.ss-main .ss-multi-selected .ss-add .ss-plus:after{background:#666;content:"";position:absolute;height:2px;width:10px;left:-4px;top:4px}.ss-main .ss-multi-selected .ss-add .ss-plus.ss-cross{transform:rotate(45deg)}.ss-content{position:absolute;width:100%;margin:-1px 0 0 0;box-sizing:border-box;border:solid 1px #dcdee2;z-index:1010;background-color:#fff;transform-origin:center top;transition:transform .2s, opacity .2s;opacity:0;transform:scaleY(0)}.ss-content.ss-open{display:block;opacity:1;transform:scaleY(1)}.ss-content .ss-search{display:flex;flex-direction:row;padding:8px 8px 6px 8px}.ss-content .ss-search.ss-hide{height:0px;opacity:0;padding:0px 0px 0px 0px;margin:0px 0px 0px 0px}.ss-content .ss-search.ss-hide input{height:0px;opacity:0;padding:0px 0px 0px 0px;margin:0px 0px 0px 0px}.ss-content .ss-search input{display:inline-flex;font-size:inherit;line-height:inherit;flex:1 1 auto;width:100%;min-width:0px;height:30px;padding:6px 8px;margin:0;border:1px solid #dcdee2;border-radius:4px;background-color:#fff;outline:0;text-align:left;box-sizing:border-box;-webkit-box-sizing:border-box;-webkit-appearance:textfield}.ss-content .ss-search input::placeholder{color:#8a8a8a;vertical-align:middle}.ss-content .ss-search input:focus{box-shadow:0 0 5px #5897fb}.ss-content .ss-search .ss-addable{display:inline-flex;justify-content:center;align-items:center;cursor:pointer;font-size:22px;font-weight:bold;flex:0 0 30px;height:30px;margin:0 0 0 8px;border:1px solid #dcdee2;border-radius:4px;box-sizing:border-box}.ss-content .ss-addable{padding-top:0px}.ss-content .ss-list{max-height:200px;overflow-x:hidden;overflow-y:auto;text-align:left}.ss-content .ss-list .ss-optgroup .ss-optgroup-label{padding:6px 10px 6px 10px;font-weight:bold}.ss-content .ss-list .ss-optgroup .ss-option{padding:6px 6px 6px 25px}.ss-content .ss-list .ss-optgroup-label-selectable{cursor:pointer}.ss-content .ss-list .ss-optgroup-label-selectable:hover{color:#fff;background-color:#5897fb}.ss-content .ss-list .ss-option{padding:6px 10px 6px 10px;cursor:pointer;user-select:none}.ss-content .ss-list .ss-option *{display:inline-block}.ss-content .ss-list .ss-option:hover,.ss-content .ss-list .ss-option.ss-highlighted{color:#fff;background-color:#5897fb}.ss-content .ss-list .ss-option.ss-disabled{cursor:not-allowed;color:#dedede;background-color:#fff}.ss-content .ss-list .ss-option:not(.ss-disabled).ss-option-selected{color:#666;background-color:rgba(88,151,251,0.1)}.ss-content .ss-list .ss-option.ss-hide{display:none}.ss-content .ss-list .ss-option .ss-search-highlight{background-color:#fffb8c} - +.ss-main { + position: relative; + display: inline-block; + user-select: none; + color: #666; + width: 100%; +} +.ss-main .ss-single-selected { + display: flex; + cursor: pointer; + width: 100%; + height: 30px; + padding: 6px; + border: 1px solid #dcdee2; + border-radius: 4px; + background-color: #fff; + outline: 0; + box-sizing: border-box; + transition: background-color .2s; +} +.ss-main .ss-single-selected.ss-disabled { + background-color: #dcdee2; + cursor: not-allowed; +} +.ss-main .ss-single-selected.ss-open-above { + border-top-left-radius: 0px; + border-top-right-radius: 0px; +} +.ss-main .ss-single-selected.ss-open-below { + border-bottom-left-radius: 0px; + border-bottom-right-radius: 0px; +} +.ss-main .ss-single-selected .placeholder { + display: flex; + flex: 1 1 100%; + align-items: center; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + text-align: left; + width: calc(100% - 30px); + line-height: 1em; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} +.ss-main .ss-single-selected .placeholder * { + display: flex; + align-items: center; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + width: auto; +} +.ss-main .ss-single-selected .placeholder .ss-disabled { + color: #dedede; +} +.ss-main .ss-single-selected .ss-deselect { + display: flex; + align-items: center; + justify-content: flex-end; + flex: 0 1 auto; + margin: 0 6px 0 6px; + font-weight: bold; +} +.ss-main .ss-single-selected .ss-deselect.ss-hide { + display: none; +} +.ss-main .ss-single-selected .ss-arrow { + display: flex; + align-items: center; + justify-content: flex-end; + flex: 0 1 auto; + margin: 0 6px 0 6px; +} +.ss-main .ss-single-selected .ss-arrow span { + border: solid #666; + border-width: 0 2px 2px 0; + display: inline-block; + padding: 3px; + transition: transform .2s, margin .2s; +} +.ss-main .ss-single-selected .ss-arrow span.arrow-up { + transform: rotate(-135deg); + margin: 3px 0 0 0; +} +.ss-main .ss-single-selected .ss-arrow span.arrow-down { + transform: rotate(45deg); + margin: -3px 0 0 0; +} +.ss-main .ss-multi-selected { + display: flex; + flex-direction: row; + cursor: pointer; + min-height: 30px; + width: 100%; + padding: 0 0 0 3px; + border: 1px solid #dcdee2; + border-radius: 4px; + background-color: #fff; + outline: 0; + box-sizing: border-box; + transition: background-color .2s; +} +.ss-main .ss-multi-selected.ss-disabled { + background-color: #dcdee2; + cursor: not-allowed; +} +.ss-main .ss-multi-selected.ss-disabled .ss-values .ss-disabled { + color: #666; +} +.ss-main .ss-multi-selected.ss-disabled .ss-values .ss-value .ss-value-delete { + cursor: not-allowed; +} +.ss-main .ss-multi-selected.ss-open-above { + border-top-left-radius: 0px; + border-top-right-radius: 0px; +} +.ss-main .ss-multi-selected.ss-open-below { + border-bottom-left-radius: 0px; + border-bottom-right-radius: 0px; +} +.ss-main .ss-multi-selected .ss-values { + display: flex; + flex-wrap: wrap; + justify-content: flex-start; + flex: 1 1 100%; + width: calc(100% - 30px); +} +.ss-main .ss-multi-selected .ss-values .ss-disabled { + display: flex; + padding: 4px 5px; + margin: 2px 0px; + line-height: 1em; + align-items: center; + width: 100%; + color: #dedede; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +@keyframes scaleIn { + 0% { + transform: scale(0); + opacity: 0; + } + 100% { + transform: scale(1); + opacity: 1; + } +} +@keyframes scaleOut { + 0% { + transform: scale(1); + opacity: 1; + } + 100% { + transform: scale(0); + opacity: 0; + } +} +.ss-main .ss-multi-selected .ss-values .ss-value { + display: flex; + user-select: none; + align-items: center; + font-size: 12px; + padding: 3px 5px; + margin: 3px 5px 3px 0px; + color: #fff; + background-color: #5897fb; + border-radius: 4px; + animation-name: scaleIn; + animation-duration: .2s; + animation-timing-function: ease-out; + animation-fill-mode: both; +} +.ss-main .ss-multi-selected .ss-values .ss-value.ss-out { + animation-name: scaleOut; + animation-duration: .2s; + animation-timing-function: ease-out; +} +.ss-main .ss-multi-selected .ss-values .ss-value .ss-value-delete { + margin: 0 0 0 5px; + cursor: pointer; +} +.ss-main .ss-multi-selected .ss-add { + display: flex; + flex: 0 1 3px; + margin: 9px 12px 0 5px; +} +.ss-main .ss-multi-selected .ss-add .ss-plus { + display: flex; + justify-content: center; + align-items: center; + background: #666; + position: relative; + height: 10px; + width: 2px; + transition: transform .2s; +} +.ss-main .ss-multi-selected .ss-add .ss-plus:after { + background: #666; + content: ""; + position: absolute; + height: 2px; + width: 10px; + left: -4px; + top: 4px; +} +.ss-main .ss-multi-selected .ss-add .ss-plus.ss-cross { + transform: rotate(45deg); +} +.ss-content { + position: absolute; + width: 100%; + margin: -1px 0 0 0; + box-sizing: border-box; + border: solid 1px #dcdee2; + z-index: 1010; + background-color: #fff; + transform-origin: center top; + transition: transform .2s, opacity .2s; + opacity: 0; + transform: scaleY(0); +} +.ss-content.ss-open { + display: block; + opacity: 1; + transform: scaleY(1); +} +.ss-content .ss-search { + display: flex; + flex-direction: row; + padding: 8px 8px 6px 8px; +} +.ss-content .ss-search.ss-hide { + height: 0px; + opacity: 0; + padding: 0px 0px 0px 0px; + margin: 0px 0px 0px 0px; +} +.ss-content .ss-search.ss-hide input { + height: 0px; + opacity: 0; + padding: 0px 0px 0px 0px; + margin: 0px 0px 0px 0px; +} +.ss-content .ss-search input { + display: inline-flex; + font-size: inherit; + line-height: inherit; + flex: 1 1 auto; + width: 100%; + min-width: 0px; + height: 30px; + padding: 6px 8px; + margin: 0; + border: 1px solid #dcdee2; + border-radius: 4px; + background-color: #fff; + outline: 0; + text-align: left; + box-sizing: border-box; + -webkit-box-sizing: border-box; + -webkit-appearance: textfield; +} +.ss-content .ss-search input::placeholder { + color: #8a8a8a; + vertical-align: middle; +} +.ss-content .ss-search input:focus { + box-shadow: 0 0 5px #5897fb; +} +.ss-content .ss-search .ss-addable { + display: inline-flex; + justify-content: center; + align-items: center; + cursor: pointer; + font-size: 22px; + font-weight: bold; + flex: 0 0 30px; + height: 30px; + margin: 0 0 0 8px; + border: 1px solid #dcdee2; + border-radius: 4px; + box-sizing: border-box; +} +.ss-content .ss-addable { + padding-top: 0px; +} +.ss-content .ss-list { + max-height: 200px; + overflow-x: hidden; + overflow-y: auto; + text-align: left; +} +.ss-content .ss-list .ss-optgroup .ss-optgroup-label { + padding: 6px 10px 6px 10px; + font-weight: bold; +} +.ss-content .ss-list .ss-optgroup .ss-option { + padding: 6px 6px 6px 25px; +} +.ss-content .ss-list .ss-optgroup-label-selectable { + cursor: pointer; +} +.ss-content .ss-list .ss-optgroup-label-selectable:hover { + color: #fff; + background-color: #5897fb; +} +.ss-content .ss-list .ss-option { + padding: 6px 10px 6px 10px; + cursor: pointer; + user-select: none; +} +.ss-content .ss-list .ss-option * { + display: inline-block; +} +.ss-content .ss-list .ss-option:hover, +.ss-content .ss-list .ss-option.ss-highlighted { + color: #fff; + background-color: #5897fb; +} +.ss-content .ss-list .ss-option.ss-disabled { + cursor: not-allowed; + color: #dedede; + background-color: #fff; +} +.ss-content .ss-list .ss-option:not(.ss-disabled).ss-option-selected { + color: #666; + background-color: rgba(88, 151, 251, 0.1); +} +.ss-content .ss-list .ss-option.ss-hide { + display: none; +} +.ss-content .ss-list .ss-option .ss-search-highlight { + background-color: #fffb8c; +} diff --git a/src/new-widgets/interfaces.ts b/src/new-widgets/interfaces.ts index e638fc9a..1b33dc64 100644 --- a/src/new-widgets/interfaces.ts +++ b/src/new-widgets/interfaces.ts @@ -1,11 +1,11 @@ import type { MixinStaticInterface } from '../libs/interfaces'; export interface Template { - template: Function - dependencies: MixinStaticInterface[] + template: Function; + dependencies: MixinStaticInterface[]; } export interface WidgetMixinsInterface { - templateMixin: Template - mixins: MixinStaticInterface[] -} \ No newline at end of file + templateMixin: Template; + mixins: MixinStaticInterface[]; +} diff --git a/src/new-widgets/new-widget-factory.ts b/src/new-widgets/new-widget-factory.ts index a3dda0d0..9760f0f8 100644 --- a/src/new-widgets/new-widget-factory.ts +++ b/src/new-widgets/new-widget-factory.ts @@ -2,7 +2,13 @@ import { Sib } from '../libs/Sib'; import { BaseWidgetMixin } from './baseWidgetMixin'; import type { Template, WidgetMixinsInterface } from './interfaces'; import type { MixinStaticInterface } from '../libs/interfaces'; -import { defaultTemplates, displayTemplates, formTemplates, setTemplates, groupTemplates } from './templates/index'; +import { + defaultTemplates, + displayTemplates, + formTemplates, + setTemplates, + groupTemplates, +} from './templates/index'; import { valueTransformationDirectory } from './valueTransformationMixins/index'; import { templateAdditionDirectory } from './templateAdditionMixins/index'; import { attributeDirectory } from './attributeMixins/index'; @@ -19,13 +25,16 @@ const callbackKeys = Object.keys(callbackDirectory); */ export const newWidgetFactory = (tagName: string) => { let widgetMixins: WidgetMixinsInterface; - try { widgetMixins = getWidgetMixins(tagName) } // get mixins and template - catch (e) { + try { + widgetMixins = getWidgetMixins(tagName); + } catch (e) { + // get mixins and template console.error(e); return; } - const newWidget = { // compose widget + const newWidget = { + // compose widget name: tagName, use: [ ...widgetMixins.mixins, @@ -93,8 +102,8 @@ function getWidgetMixins(tagName: string): WidgetMixinsInterface { ...templateAdditions, ...(template.dependencies || []), ...callbacks, - ] - } + ], + }; } // create default widgets @@ -102,4 +111,4 @@ newWidgetFactory('solid-form-dropdown'); newWidgetFactory('solid-form-multicheckbox'); newWidgetFactory('solid-form-file-label'); newWidgetFactory('solid-action'); -newWidgetFactory('solid-group-default'); \ No newline at end of file +newWidgetFactory('solid-group-default'); diff --git a/src/new-widgets/templateAdditionMixins/addableMixin.ts b/src/new-widgets/templateAdditionMixins/addableMixin.ts index edd6c3f8..e0b2a897 100644 --- a/src/new-widgets/templateAdditionMixins/addableMixin.ts +++ b/src/new-widgets/templateAdditionMixins/addableMixin.ts @@ -6,16 +6,27 @@ import { html } from 'lit'; const AddableMixin = { name: 'addable-mixin', created() { - this.listTemplateAdditions.attach(this.addableValue.bind(this), "AddableMixin:addableValue"); + this.listTemplateAdditions.attach( + this.addableValue.bind(this), + 'AddableMixin:addableValue', + ); }, getAddableAttributes() { - const addableAttr = (Array.from(this.element.attributes) as Attr[]).filter((a: Attr) => a.name.startsWith('addable-')); + const addableAttr = (Array.from(this.element.attributes) as Attr[]).filter( + (a: Attr) => a.name.startsWith('addable-'), + ); const cleanAddableAttr: { [key: string]: string } = {}; - for (let attr of addableAttr) cleanAddableAttr[attr.name.replace('addable-', '')] = attr.value; - if (!cleanAddableAttr.hasOwnProperty('data-src')) cleanAddableAttr['data-src'] = this.range; + for (let attr of addableAttr) + cleanAddableAttr[attr.name.replace('addable-', '')] = attr.value; + if (!cleanAddableAttr.hasOwnProperty('data-src')) + cleanAddableAttr['data-src'] = this.range; return cleanAddableAttr; }, - addableValue(template, listTemplateAdditions: PostProcessorRegistry, attributes: object) { + addableValue( + template, + listTemplateAdditions: PostProcessorRegistry, + attributes: object, + ) { const addables = this.getAddableAttributes(attributes); const newTemplate = html` ${template} @@ -25,9 +36,7 @@ const AddableMixin = { const nextProcessor = listTemplateAdditions.shift(); if (nextProcessor) nextProcessor(newTemplate, listTemplateAdditions); - } -} + }, +}; -export { - AddableMixin -} \ No newline at end of file +export { AddableMixin }; diff --git a/src/new-widgets/templateAdditionMixins/index.ts b/src/new-widgets/templateAdditionMixins/index.ts index ad720767..7f3c163a 100644 --- a/src/new-widgets/templateAdditionMixins/index.ts +++ b/src/new-widgets/templateAdditionMixins/index.ts @@ -9,11 +9,6 @@ const templateAdditionDirectory = { label: LabelMixin, labellast: LabelLastMixin, addable: AddableMixin, -} +}; -export { - templateAdditionDirectory, - LabelMixin, - LabelLastMixin, - AddableMixin, -} +export { templateAdditionDirectory, LabelMixin, LabelLastMixin, AddableMixin }; diff --git a/src/new-widgets/templateAdditionMixins/labelLastMixin.ts b/src/new-widgets/templateAdditionMixins/labelLastMixin.ts index f1136d4b..f454db39 100644 --- a/src/new-widgets/templateAdditionMixins/labelLastMixin.ts +++ b/src/new-widgets/templateAdditionMixins/labelLastMixin.ts @@ -4,16 +4,17 @@ import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const LabelLastMixin = { name: 'label-last-mixin', created() { - this.listTemplateAdditions.attach(this.addLabelLast.bind(this), "LabelLastMixin:addLabelLast"); + this.listTemplateAdditions.attach( + this.addLabelLast.bind(this), + 'LabelLastMixin:addLabelLast', + ); }, addLabelLast(template, listTemplateAdditions: PostProcessorRegistry) { const newTemplate = html`${template}<label>${this.label || this.name}</label>`; const nextProcessor = listTemplateAdditions.shift(); if (nextProcessor) nextProcessor(newTemplate, listTemplateAdditions); - } -} + }, +}; -export { - LabelLastMixin -} \ No newline at end of file +export { LabelLastMixin }; diff --git a/src/new-widgets/templateAdditionMixins/labelMixin.ts b/src/new-widgets/templateAdditionMixins/labelMixin.ts index ac938f54..e725e08a 100644 --- a/src/new-widgets/templateAdditionMixins/labelMixin.ts +++ b/src/new-widgets/templateAdditionMixins/labelMixin.ts @@ -5,17 +5,18 @@ import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const LabelMixin = { name: 'label-mixin', created() { - this.listAttributes['id'] = uniqID(); - this.listTemplateAdditions.attach(this.addLabel.bind(this), "LabelMixin:addLabel"); + this.listAttributes['id'] = uniqID(); + this.listTemplateAdditions.attach( + this.addLabel.bind(this), + 'LabelMixin:addLabel', + ); }, addLabel(template, listTemplateAdditions: PostProcessorRegistry) { const newTemplate = html`<label for="${this.listAttributes['id']}">${this.label || this.name}</label>${template}`; const nextProcessor = listTemplateAdditions.shift(); if (nextProcessor) nextProcessor(newTemplate, listTemplateAdditions); - } -} + }, +}; -export { - LabelMixin -} \ No newline at end of file +export { LabelMixin }; diff --git a/src/new-widgets/templates/defaultTemplatesDirectory.ts b/src/new-widgets/templates/defaultTemplatesDirectory.ts index 9d64d2a0..faed3415 100644 --- a/src/new-widgets/templates/defaultTemplatesDirectory.ts +++ b/src/new-widgets/templates/defaultTemplatesDirectory.ts @@ -11,10 +11,10 @@ export const defaultTemplates = { id=${ifDefined(attributes.id)} link-text=${ifDefined(attributes.linkText)} > - ${attributes.linkText == null ? (attributes.name || '') : attributes.linkText} + ${attributes.linkText == null ? attributes.name || '' : attributes.linkText} </solid-link> `, - dependencies: [LinkTextMixin] + dependencies: [LinkTextMixin], }, multiple: { template: (value: string, attributes: any) => html` @@ -25,6 +25,6 @@ export const defaultTemplates = { empty-widget=${ifDefined(attributes.emptyWidget)} ></solid-display> `, - dependencies: [] + dependencies: [], }, -} +}; diff --git a/src/new-widgets/templates/displayTemplatesDirectory.ts b/src/new-widgets/templates/displayTemplatesDirectory.ts index 7ca569f2..fb17056b 100644 --- a/src/new-widgets/templates/displayTemplatesDirectory.ts +++ b/src/new-widgets/templates/displayTemplatesDirectory.ts @@ -8,17 +8,18 @@ import { ifDefined } from 'lit/directives/if-defined.js'; export const displayTemplates = { value: { template: (value: string) => html`${value}`, - dependencies: [] + dependencies: [], }, div: { - template: (value: string, attributes: any) => html`<div name=${ifDefined(attributes.name)} ?data-editable=${attributes.editable}>${value}</div>`, - dependencies: [ EditableMixin ] + template: (value: string, attributes: any) => + html`<div name=${ifDefined(attributes.name)} ?data-editable=${attributes.editable}>${value}</div>`, + dependencies: [EditableMixin], }, link: { template: (value: string, attributes: any) => html` <a name=${ifDefined(attributes.name)} - href=${(attributes.mailto || attributes.tel || '')+(value || '#')} + href=${(attributes.mailto || attributes.tel || '') + (value || '#')} target=${ifDefined(attributes.target)} ?data-editable=${attributes.editable} id=${ifDefined(attributes.id)} @@ -27,7 +28,7 @@ export const displayTemplates = { ${attributes.linkText || value || ''} </a> `, - dependencies: [ EditableMixin, LinkTextMixin ] + dependencies: [EditableMixin, LinkTextMixin], }, img: { template: (value: string, attributes: any) => html` @@ -38,10 +39,11 @@ export const displayTemplates = { style="max-width: 100%; max-height: 100%;" /> `, - dependencies: [AltMixin] + dependencies: [AltMixin], }, boolean: { - template: (value: string, attributes: any) => html`${value === 'true' ? html`<label>${attributes.label || attributes.name || ''}</label>` : ''}`, - dependencies: [] + template: (value: string, attributes: any) => + html`${value === 'true' ? html`<label>${attributes.label || attributes.name || ''}</label>` : ''}`, + dependencies: [], }, -} +}; diff --git a/src/new-widgets/templates/formTemplatesDirectory.ts b/src/new-widgets/templates/formTemplatesDirectory.ts index abc03ecd..5c1cc1d1 100644 --- a/src/new-widgets/templates/formTemplatesDirectory.ts +++ b/src/new-widgets/templates/formTemplatesDirectory.ts @@ -37,7 +37,7 @@ export const formTemplates = { @change=${attributes.onChange} /> `, - dependencies: [ FormMixin, PatternMixin, FormLengthMixin ] + dependencies: [FormMixin, PatternMixin, FormLengthMixin], }, textarea: { template: (value: string, attributes: any) => html` @@ -53,7 +53,7 @@ export const formTemplates = { @change=${attributes.onChange} >${value}</textarea> `, - dependencies: [ FormMixin, FormLengthMixin ] + dependencies: [FormMixin, FormLengthMixin], }, checkbox: { template: (value: string, attributes: any) => html` @@ -69,7 +69,7 @@ export const formTemplates = { <div>${attributes.label || attributes.name}</div> </label> `, - dependencies: [ FormCheckboxMixin, FormMixin ] + dependencies: [FormCheckboxMixin, FormMixin], }, date: { template: (_value: string, attributes: any) => html` @@ -84,7 +84,7 @@ export const formTemplates = { @change=${attributes.onChange} /> `, - dependencies: [ FormMixin ] + dependencies: [FormMixin], }, rangedate: { template: (_value: string, attributes: any) => html` @@ -103,7 +103,7 @@ export const formTemplates = { value=${ifDefined(attributes.endValue)} /> `, - dependencies: [ FilterRangeFormMixin, FormMixin ] + dependencies: [FilterRangeFormMixin, FormMixin], }, number: { template: (value: string, attributes: any) => html` @@ -121,7 +121,7 @@ export const formTemplates = { @change=${attributes.onChange} /> `, - dependencies: [ FormNumberMixin, FormMinMaxMixin, FormMixin, FormStepMixin ] + dependencies: [FormNumberMixin, FormMinMaxMixin, FormMixin, FormStepMixin], }, rangenumber: { template: (_value: string, attributes: any) => html` @@ -140,7 +140,7 @@ export const formTemplates = { value=${ifDefined(attributes.endValue)} /> `, - dependencies: [ FilterRangeFormMixin, FormNumberMixin, FormMixin ] + dependencies: [FilterRangeFormMixin, FormNumberMixin, FormMixin], }, hidden: { template: (value: string, attributes: any) => html` @@ -152,7 +152,7 @@ export const formTemplates = { @change=${attributes.onChange} /> `, - dependencies: [ FormMixin ] + dependencies: [FormMixin], }, dropdown: { template: (value: string, attributes: any) => html` @@ -165,37 +165,46 @@ export const formTemplates = { autocomplete=${ifDefined(attributes.autocomplete)} @change=${attributes.onChange} > - ${!(attributes.multiple || attributes.autocomplete) ? html` - <option value="" ?selected=${value === ""}> + ${ + !(attributes.multiple || attributes.autocomplete) + ? html` + <option value="" ?selected=${value === ''}> ${attributes.placeholder || '-'} </option> - ` : ''} - ${(attributes.range || []).map(el => html` + ` + : '' + } + ${(attributes.range || []).map( + el => html` <option value=${el.value} ?selected=${!attributes.multiple ? value === el.selectedValue : attributes.values.includes(el.selectedValue)} > ${el.label} </option> - `)} - ${Object.entries(attributes.enum || []).map(([key, val]) => html` + `, + )} + ${Object.entries(attributes.enum || []).map( + ([key, val]) => html` <option value="${key}" ?selected=${!attributes.multiple ? value === key : attributes.values.includes(key)} > ${val} </option> - `)} + `, + )} </select> `, - dependencies: [ FormDropdownMixin, FormMixin, RangeMixin ] + dependencies: [FormDropdownMixin, FormMixin, RangeMixin], }, radio: { template: (value: string, attributes: any) => html` <div name=${ifDefined(attributes.name)} > - ${(attributes.range || []).map(el => html` + ${(attributes.range || []).map( + el => html` <label> <input type="radio" @@ -205,8 +214,10 @@ export const formTemplates = { ?checked=${value === el.selectedValue} > <span>${el.label}</span> </label> - `)} - ${Object.entries(attributes.enum || []).map(([key, val]) => html` + `, + )} + ${Object.entries(attributes.enum || []).map( + ([key, val]) => html` <label> <input type="radio" @@ -216,16 +227,18 @@ export const formTemplates = { ?checked=${value === key} > <span>${val}</span> </label> - `)} + `, + )} `, - dependencies: [ FormRadioMixin, FormMixin, RangeMixin ] + dependencies: [FormRadioMixin, FormMixin, RangeMixin], }, multicheckbox: { template: (_value: string, attributes: any) => html` <div name=${ifDefined(attributes.name)} > - ${(attributes.range || []).map(el => html` + ${(attributes.range || []).map( + el => html` <label> <input type="checkbox" @@ -233,18 +246,20 @@ export const formTemplates = { ?checked=${attributes.values.includes(el.selectedValue)} /> <span>${el.label}</span> </label> - `)} - ${Object.entries(attributes.enum || []) - .map(([key, val]) => html` + `, + )} + ${Object.entries(attributes.enum || []).map( + ([key, val]) => html` <label> <input type="checkbox" value="${key}" /> <span>${val}</span> </label> - `)} + `, + )} </select> `, - dependencies: [ FormCheckboxesMixin, FormMixin, RangeMixin ] + dependencies: [FormCheckboxesMixin, FormMixin, RangeMixin], }, checkboxes: { template: (_value: string, attributes: any) => html` @@ -261,19 +276,21 @@ export const formTemplates = { ?required=${attributes.required} ></solid-form-multicheckbox> `, - dependencies: [ MultipleselectFormMixin, FormMixin, RangeMixin ] + dependencies: [MultipleselectFormMixin, FormMixin, RangeMixin], }, multiple: { template: (_value: string, attributes: any) => html` - ${(attributes.children || []).map((child, index) => html` + ${(attributes.children || []).map( + (child, index) => html` <div data-index=${attributes.name + index}> ${child} <button type="button" class=${ifDefined(attributes.removeClass)} @click=${() => attributes.removeItem(index)}>${attributes.removeLabel}</button> </div> - `)} + `, + )} <button type="button" class=${ifDefined(attributes.addClass)} @click=${attributes.addItem}>${attributes.addLabel}</button> `, - dependencies: [ MultipleFormMixin, FormMixin ] + dependencies: [MultipleFormMixin, FormMixin], }, multipleselect: { template: (_value: string, attributes: any) => html` @@ -291,7 +308,7 @@ export const formTemplates = { multiple ></solid-form-dropdown> `, - dependencies: [ MultipleselectFormMixin, FormMixin, RangeMixin ] + dependencies: [MultipleselectFormMixin, FormMixin, RangeMixin], }, file: { template: (value: string, attributes: any) => html` @@ -306,7 +323,7 @@ export const formTemplates = { <a href=${value || ''} ?hidden=${value === ''} - >${ ((value !== '') ? decodeURI(value.split("/").pop() as string) : '' ) }</a> + >${value !== '' ? decodeURI(value.split('/').pop() as string) : ''}</a> <input type="file" @@ -321,7 +338,7 @@ export const formTemplates = { <span>${attributes.output}</span> </div> `, - dependencies: [ FormFileMixin, FormMixin ] + dependencies: [FormFileMixin, FormMixin], }, image: { template: (value: string, attributes: any) => html` @@ -351,7 +368,7 @@ export const formTemplates = { <span>${attributes.output}</span> </div> `, - dependencies: [ FormFileMixin, FormMixin ] + dependencies: [FormFileMixin, FormMixin], }, richtext: { template: (_value: string, attributes: any) => html` @@ -361,7 +378,7 @@ export const formTemplates = { data-holder ></div> `, - dependencies: [ ValueRichtextMixin, FormMixin ] + dependencies: [ValueRichtextMixin, FormMixin], }, color: { template: (_value: string, attributes: any) => html` @@ -376,7 +393,7 @@ export const formTemplates = { @change=${attributes.onChange} /> `, - dependencies: [ FormMixin ] + dependencies: [FormMixin], }, email: { template: (value: string, attributes: any) => html` @@ -385,7 +402,7 @@ export const formTemplates = { placeholder=${ifDefined(attributes.placeholder)} id=${ifDefined(attributes.id)} name=${ifDefined(attributes.name)} - value=${value || ''} + value=${value || ''} ?required=${attributes.required} data-holder maxlength=${ifDefined(attributes.maxlength)} @@ -393,7 +410,7 @@ export const formTemplates = { @change=${attributes.onChange} /> `, - dependencies: [ FormMixin, FormLengthMixin ] + dependencies: [FormMixin, FormLengthMixin], }, password: { template: (value: string, attributes: any) => html` @@ -402,7 +419,7 @@ export const formTemplates = { placeholder=${ifDefined(attributes.placeholder)} id=${ifDefined(attributes.id)} name=${ifDefined(attributes.name)} - value=${value || ''} + value=${value || ''} ?required=${attributes.required} pattern=${ifDefined(attributes.pattern)} title=${ifDefined(attributes.title)} @@ -412,7 +429,7 @@ export const formTemplates = { @change=${attributes.onChange} /> `, - dependencies: [ FormMixin, PatternMixin, FormLengthMixin ] + dependencies: [FormMixin, PatternMixin, FormLengthMixin], }, time: { template: (value: string, attributes: any) => html` @@ -430,6 +447,6 @@ export const formTemplates = { @change=${attributes.onChange} /> `, - dependencies: [ FormMixin, FormMinMaxMixin, FormStepMixin ] + dependencies: [FormMixin, FormMinMaxMixin, FormStepMixin], }, -} +}; diff --git a/src/new-widgets/templates/groupTemplatesDirectory.ts b/src/new-widgets/templates/groupTemplatesDirectory.ts index 511e5ae9..c1c4997b 100644 --- a/src/new-widgets/templates/groupTemplatesDirectory.ts +++ b/src/new-widgets/templates/groupTemplatesDirectory.ts @@ -3,7 +3,8 @@ import { SetMixin } from '../templatesDependencies/setMixin'; export const groupTemplates = { default: { - template: (value: string) => html`<span>${value}</span><div data-content></div>`, - dependencies: [SetMixin] + template: (value: string) => + html`<span>${value}</span><div data-content></div>`, + dependencies: [SetMixin], }, -} \ No newline at end of file +}; diff --git a/src/new-widgets/templates/index.ts b/src/new-widgets/templates/index.ts index 288fcd3b..853d1383 100644 --- a/src/new-widgets/templates/index.ts +++ b/src/new-widgets/templates/index.ts @@ -9,5 +9,5 @@ export { displayTemplates, formTemplates, setTemplates, - groupTemplates -} + groupTemplates, +}; diff --git a/src/new-widgets/templates/setTemplatesDirectory.ts b/src/new-widgets/templates/setTemplatesDirectory.ts index 0e0580b0..59c8de16 100644 --- a/src/new-widgets/templates/setTemplatesDirectory.ts +++ b/src/new-widgets/templates/setTemplatesDirectory.ts @@ -4,14 +4,14 @@ import { SetMixin } from '../templatesDependencies/setMixin'; export const setTemplates = { default: { template: () => html``, - dependencies: [ SetMixin ] + dependencies: [SetMixin], }, div: { template: () => html`<div data-content></div>`, - dependencies: [ SetMixin ] + dependencies: [SetMixin], }, ul: { template: () => html`<ul data-content></ul>`, - dependencies: [ SetMixin ] - } -} \ No newline at end of file + dependencies: [SetMixin], + }, +}; diff --git a/src/new-widgets/templatesDependencies/altMixin.ts b/src/new-widgets/templatesDependencies/altMixin.ts index 3e517c3c..1d0a1821 100644 --- a/src/new-widgets/templatesDependencies/altMixin.ts +++ b/src/new-widgets/templatesDependencies/altMixin.ts @@ -1,15 +1,13 @@ const AltMixin = { name: 'alt-mixin', - attributes : { - alt : { + attributes: { + alt: { type: String, callback: function (newValue: string) { - this.addToAttributes(newValue, 'alt') - } + this.addToAttributes(newValue, 'alt'); + }, }, }, -} +}; -export { - AltMixin -} \ No newline at end of file +export { AltMixin }; diff --git a/src/new-widgets/templatesDependencies/editableMixin.ts b/src/new-widgets/templatesDependencies/editableMixin.ts index c0d9bba5..77107114 100644 --- a/src/new-widgets/templatesDependencies/editableMixin.ts +++ b/src/new-widgets/templatesDependencies/editableMixin.ts @@ -6,26 +6,29 @@ import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const EditableMixin = { name: 'editable-mixin', - use: [ StoreMixin ], // used to get context + use: [StoreMixin], // used to get context attributes: { editable: { type: Boolean, default: null, callback: function (newValue: boolean) { if (newValue !== null) this.listAttributes['editable'] = true; - } + }, }, valueId: { type: String, - default: '' + default: '', }, buttonLabel: { type: String, - default: 'Modifier' - } + default: 'Modifier', + }, }, created() { - this.listTemplateAdditions.attach(this.addEditButton.bind(this), "EditableMixin:addEditButton"); + this.listTemplateAdditions.attach( + this.addEditButton.bind(this), + 'EditableMixin:addEditButton', + ); }, addEditButton(template, listTemplateAdditions: PostProcessorRegistry) { let newTemplate: any = null; @@ -33,7 +36,8 @@ const EditableMixin = { newTemplate = html`${template}<button @click=${this.activateEditableField.bind(this)}>${this.buttonLabel}</button>`; } const nextProcessor = listTemplateAdditions.shift(); - if (nextProcessor) nextProcessor(newTemplate || template, listTemplateAdditions); + if (nextProcessor) + nextProcessor(newTemplate || template, listTemplateAdditions); }, activateEditableField(e: Event): void { const editableField = this.element.querySelector('[data-editable]'); @@ -45,7 +49,9 @@ const EditableMixin = { editButton.toggleAttribute('disabled', true); // Save on focusout - editableField.addEventListener('focusout', () => this.save(editableField, editButton)); + editableField.addEventListener('focusout', () => + this.save(editableField, editButton), + ); }, save(editableField: HTMLElement, editButton: HTMLElement) { editableField.toggleAttribute('contenteditable', false); @@ -61,8 +67,6 @@ const EditableMixin = { store.patch(resource, this.valueId); }, -} +}; -export { - EditableMixin -} \ No newline at end of file +export { EditableMixin }; diff --git a/src/new-widgets/templatesDependencies/filterRangeFormMixin.ts b/src/new-widgets/templatesDependencies/filterRangeFormMixin.ts index 63c4b868..3bd559dd 100644 --- a/src/new-widgets/templatesDependencies/filterRangeFormMixin.ts +++ b/src/new-widgets/templatesDependencies/filterRangeFormMixin.ts @@ -3,36 +3,36 @@ const FilterRangeFormMixin = { attributes: { startValue: { type: String, - default:'', + default: '', callback: function (value: string) { - this.addToAttributes(this.getDefaultValue(value), "startValue") - } + this.addToAttributes(this.getDefaultValue(value), 'startValue'); + }, }, endValue: { type: String, - default:'', + default: '', callback: function (value: string) { - this.addToAttributes(this.getDefaultValue(value), "endValue") - } - } + this.addToAttributes(this.getDefaultValue(value), 'endValue'); + }, + }, }, getDefaultValue(value) { - if (value == "today") return new Date().toISOString().split("T")[0]; + if (value == 'today') return new Date().toISOString().split('T')[0]; return value; }, getValue() { if (!this.dataHolder) return []; - if (this.dataHolder.length !== 2) this.showDataHolderError(2, this.dataHolder.length); - return [ // we expect 2 values, one min and one max + if (this.dataHolder.length !== 2) + this.showDataHolderError(2, this.dataHolder.length); + return [ + // we expect 2 values, one min and one max this.getValueFromElement(this.dataHolder[0]), - this.getValueFromElement(this.dataHolder[1]) - ] + this.getValueFromElement(this.dataHolder[1]), + ]; }, get type() { return 'range'; }, -} +}; -export { - FilterRangeFormMixin -} \ No newline at end of file +export { FilterRangeFormMixin }; diff --git a/src/new-widgets/templatesDependencies/formCheckboxMixin.ts b/src/new-widgets/templatesDependencies/formCheckboxMixin.ts index 0d7d906b..5b6fcb1a 100644 --- a/src/new-widgets/templatesDependencies/formCheckboxMixin.ts +++ b/src/new-widgets/templatesDependencies/formCheckboxMixin.ts @@ -6,8 +6,6 @@ const FormCheckboxMixin = { get type() { return 'boolean'; }, -} +}; -export { - FormCheckboxMixin -} \ No newline at end of file +export { FormCheckboxMixin }; diff --git a/src/new-widgets/templatesDependencies/formCheckboxesMixin.ts b/src/new-widgets/templatesDependencies/formCheckboxesMixin.ts index 76c8d7e5..60666f56 100644 --- a/src/new-widgets/templatesDependencies/formCheckboxesMixin.ts +++ b/src/new-widgets/templatesDependencies/formCheckboxesMixin.ts @@ -14,31 +14,33 @@ const FormCheckboxesMixin = { } this.render(); this.element.dispatchEvent(new Event('change')); - } + }, }, }, created() { this.listAttributes['values'] = []; }, getValue() { - const options = Array.from(this.element.querySelectorAll('input')) as HTMLInputElement[]; + const options = Array.from( + this.element.querySelectorAll('input'), + ) as HTMLInputElement[]; return options .filter(el => el.checked) .map(el => { if (!el.value) return null; let value = el.value; - try { value = JSON.parse(el.value) } catch (e) { } + try { + value = JSON.parse(el.value); + } catch (e) {} return value; - }) + }); }, get type() { - return this.enum === ''? 'resource' : 'string'; + return this.enum === '' ? 'resource' : 'string'; }, get multiple() { return true; - } -} + }, +}; -export { - FormCheckboxesMixin -} \ No newline at end of file +export { FormCheckboxesMixin }; diff --git a/src/new-widgets/templatesDependencies/formDropdownMixin.ts b/src/new-widgets/templatesDependencies/formDropdownMixin.ts index a43b70ac..18f3d305 100644 --- a/src/new-widgets/templatesDependencies/formDropdownMixin.ts +++ b/src/new-widgets/templatesDependencies/formDropdownMixin.ts @@ -1,10 +1,11 @@ const FormDropdownMixin = { name: 'form-dropdown-mixin', attributes: { - values: { // used to set more than 1 value, for multiple select + values: { + // used to set more than 1 value, for multiple select type: String, default: '', - callback: function(value) { + callback: function (value) { if (value) { try { this.listAttributes['values'] = JSON.parse(value); @@ -15,20 +16,22 @@ const FormDropdownMixin = { this.render(); // use render to make sure the dispatch always happen after this.dispatchChange(); } - } + }, }, dataId: { type: String, default: '', callback: function (newValue: string) { this.addToAttributes(newValue, 'id'); - } + }, }, }, created() { this.listAttributes['values'] = []; - if (this.listAttributes['value'] && - !(JSON.parse(this.listAttributes['value']['@id'])) && Array.isArray(JSON.parse(this.listAttributes['value'])) + if ( + this.listAttributes['value'] && + !JSON.parse(this.listAttributes['value']['@id']) && + Array.isArray(JSON.parse(this.listAttributes['value'])) ) { this.listAttributes['values'] = this.listAttributes['value']; } @@ -40,23 +43,27 @@ const FormDropdownMixin = { }, getValue() { if (!this.dataHolder) return ''; // no value - if (!this.multiple) { // simple select - if (this.dataHolder.length > 1) this.showDataHolderError(1, this.dataHolder.length); + if (!this.multiple) { + // simple select + if (this.dataHolder.length > 1) + this.showDataHolderError(1, this.dataHolder.length); return this.getValueFromElement(this.dataHolder[0]); } // multiple select - const options = Array.from(this.element.querySelectorAll('option')) as HTMLOptionElement[]; - return options.filter(el => el.selected).map(el => el.value ? JSON.parse(el.value) : null) + const options = Array.from( + this.element.querySelectorAll('option'), + ) as HTMLOptionElement[]; + return options + .filter(el => el.selected) + .map(el => (el.value ? JSON.parse(el.value) : null)); }, get type() { - return this.enum === ''? 'resource' : 'string'; + return this.enum === '' ? 'resource' : 'string'; }, get multiple() { return this.element.hasAttribute('multiple'); - } -} + }, +}; -export { - FormDropdownMixin -} \ No newline at end of file +export { FormDropdownMixin }; diff --git a/src/new-widgets/templatesDependencies/formFileMixin.ts b/src/new-widgets/templatesDependencies/formFileMixin.ts index 7b594b8b..4296e530 100644 --- a/src/new-widgets/templatesDependencies/formFileMixin.ts +++ b/src/new-widgets/templatesDependencies/formFileMixin.ts @@ -1,15 +1,15 @@ -import { store } from "../../libs/store/store"; +import { store } from '../../libs/store/store'; const FormFileMixin = { name: 'form-file-mixin', attributes: { uploadUrl: { type: String, - default: '' + default: '', }, }, initialState: { - initialValue: '' + initialValue: '', }, created() { this.listAttributes['output'] = ''; @@ -18,8 +18,12 @@ const FormFileMixin = { this.listAttributes['resetFile'] = this.resetFile.bind(this); }, attached() { - this.element.closest('form').addEventListener('reset', this.resetFormFile.bind(this)) - this.element.closest('solid-form').addEventListener('populate', this.onPopulate.bind(this)) + this.element + .closest('form') + .addEventListener('reset', this.resetFormFile.bind(this)); + this.element + .closest('solid-form') + .addEventListener('populate', this.onPopulate.bind(this)); }, onPopulate() { const dataHolder = this.element.querySelector('input[data-holder]'); @@ -28,7 +32,7 @@ const FormFileMixin = { }, resetFormFile(e) { if (e.target && (e.target as HTMLElement).contains(this.element)) { - if (this.initialValue !== "") { + if (this.initialValue !== '') { this.value = this.initialValue; } this.listAttributes['resetButtonHidden'] = true; @@ -55,11 +59,12 @@ const FormFileMixin = { const file = filePicker.files![0]; const formData = new FormData(); formData.append('file', file); - store.fetchAuthn(this.uploadUrl, { - method: 'POST', - body: formData, - }) - .then(response => this.updateFile(dataHolder, response) ) + store + .fetchAuthn(this.uploadUrl, { + method: 'POST', + body: formData, + }) + .then(response => this.updateFile(dataHolder, response)) .catch(error => { this.listAttributes['fileValue'] = ''; this.listAttributes['output'] = 'upload error'; @@ -90,7 +95,7 @@ const FormFileMixin = { const filePicker = this.element.querySelector('input[type="file"]'); const dataHolder = this.element.querySelector('input[data-holder]'); - if (filePicker && dataHolder ) { + if (filePicker && dataHolder) { filePicker.value = dataHolder.value = ''; } @@ -99,9 +104,7 @@ const FormFileMixin = { this.listAttributes['resetButtonHidden'] = true; dataHolder.dispatchEvent(new Event('change')); this.planRender(); - } -} + }, +}; -export { - FormFileMixin -} +export { FormFileMixin }; diff --git a/src/new-widgets/templatesDependencies/formLengthMixin.ts b/src/new-widgets/templatesDependencies/formLengthMixin.ts index 9121410f..628796b6 100644 --- a/src/new-widgets/templatesDependencies/formLengthMixin.ts +++ b/src/new-widgets/templatesDependencies/formLengthMixin.ts @@ -5,17 +5,15 @@ const FormLengthMixin = { type: Number, callback: function (newValue: string) { this.addToAttributes(newValue, 'maxlength'); - } + }, }, minlength: { type: Number, callback: function (newValue: string) { this.addToAttributes(newValue, 'minlength'); - } + }, }, }, -} +}; -export { - FormLengthMixin -} \ No newline at end of file +export { FormLengthMixin }; diff --git a/src/new-widgets/templatesDependencies/formMinMaxMixin.ts b/src/new-widgets/templatesDependencies/formMinMaxMixin.ts index f83c8794..fe964c2a 100644 --- a/src/new-widgets/templatesDependencies/formMinMaxMixin.ts +++ b/src/new-widgets/templatesDependencies/formMinMaxMixin.ts @@ -1,21 +1,19 @@ const FormMinMaxMixin = { name: 'form-min-max-mixin', - attributes : { - min : { + attributes: { + min: { type: Number, callback: function (newValue: number) { this.addToAttributes(newValue, 'min'); - } + }, }, - max : { + max: { type: Number, callback: function (newValue: number) { this.addToAttributes(newValue, 'max'); - } + }, }, - } -} + }, +}; -export { - FormMinMaxMixin -} \ No newline at end of file +export { FormMinMaxMixin }; diff --git a/src/new-widgets/templatesDependencies/formMixin.ts b/src/new-widgets/templatesDependencies/formMixin.ts index 65bbd892..7ebf9384 100644 --- a/src/new-widgets/templatesDependencies/formMixin.ts +++ b/src/new-widgets/templatesDependencies/formMixin.ts @@ -6,14 +6,14 @@ const FormMixin = { default: false, callback: function () { this.listAttributes['required'] = true; - } + }, }, autocomplete: { type: String, default: '', - callback:function (value: string) { - this.addToAttributes(value, "autocomplete"); - } + callback: function (value: string) { + this.addToAttributes(value, 'autocomplete'); + }, }, }, attached() { @@ -26,7 +26,8 @@ const FormMixin = { }, getValue() { if (!this.dataHolder || this.dataHolder.length === 0) return this.value; - if (this.dataHolder.length > 1) this.showDataHolderError(1, this.dataHolder.length); + if (this.dataHolder.length > 1) + this.showDataHolderError(1, this.dataHolder.length); return this.getValueFromElement(this.dataHolder[0]); }, get type() { @@ -36,11 +37,19 @@ const FormMixin = { return false; }, get dataHolder(): Element[] | null { - const dataHolders = Array.from((this.element as Element).querySelectorAll('[data-holder]')); + const dataHolders = Array.from( + (this.element as Element).querySelectorAll('[data-holder]'), + ); const widgetDataHolders = dataHolders.filter(element => { - const dataHolderAncestor = element.parentElement ? element.parentElement.closest('[data-holder]') : null; + const dataHolderAncestor = element.parentElement + ? element.parentElement.closest('[data-holder]') + : null; // get the dataHolder of the widget only if no dataHolder ancestor in the current widget - return dataHolderAncestor === this.element || !dataHolderAncestor || !this.element.contains(dataHolderAncestor) + return ( + dataHolderAncestor === this.element || + !dataHolderAncestor || + !this.element.contains(dataHolderAncestor) + ); }); return widgetDataHolders.length ? widgetDataHolders : null; @@ -49,10 +58,10 @@ const FormMixin = { return element.component ? element.component.getValue() : element.value; }, showDataHolderError(expected: number, found: number) { - console.warn(`Expected ${expected} data-holder element in ${this.element.tagName}. Found ${found}`); - } -} + console.warn( + `Expected ${expected} data-holder element in ${this.element.tagName}. Found ${found}`, + ); + }, +}; -export { - FormMixin -} \ No newline at end of file +export { FormMixin }; diff --git a/src/new-widgets/templatesDependencies/formNumberMixin.ts b/src/new-widgets/templatesDependencies/formNumberMixin.ts index b6826767..3949343e 100644 --- a/src/new-widgets/templatesDependencies/formNumberMixin.ts +++ b/src/new-widgets/templatesDependencies/formNumberMixin.ts @@ -3,11 +3,9 @@ const FormNumberMixin = { getValueFromElement(element: any) { return element.value ? Number(element.value) : ''; }, - get type () { - return 'number' + get type() { + return 'number'; }, -} +}; -export { - FormNumberMixin -} \ No newline at end of file +export { FormNumberMixin }; diff --git a/src/new-widgets/templatesDependencies/formRadioMixin.ts b/src/new-widgets/templatesDependencies/formRadioMixin.ts index 29bea1d6..ba012562 100644 --- a/src/new-widgets/templatesDependencies/formRadioMixin.ts +++ b/src/new-widgets/templatesDependencies/formRadioMixin.ts @@ -6,11 +6,11 @@ const FormRadioMixin = { this.listAttributes['id'] = uniqID(); }, getValue() { - const checkedElement = this.element.querySelector('input[type=radio]:checked') as HTMLInputElement; + const checkedElement = this.element.querySelector( + 'input[type=radio]:checked', + ) as HTMLInputElement; return checkedElement ? checkedElement.value : ''; }, -} +}; -export { - FormRadioMixin -} \ No newline at end of file +export { FormRadioMixin }; diff --git a/src/new-widgets/templatesDependencies/formStepMixin.ts b/src/new-widgets/templatesDependencies/formStepMixin.ts index 292d2fc4..9ba7f9ea 100644 --- a/src/new-widgets/templatesDependencies/formStepMixin.ts +++ b/src/new-widgets/templatesDependencies/formStepMixin.ts @@ -1,15 +1,13 @@ const FormStepMixin = { name: 'form-time-mixin', - attributes : { - step : { + attributes: { + step: { type: Number, callback: function (newValue: number) { this.addToAttributes(newValue, 'step'); - } + }, }, }, -} +}; -export { - FormStepMixin -} \ No newline at end of file +export { FormStepMixin }; diff --git a/src/new-widgets/templatesDependencies/index.ts b/src/new-widgets/templatesDependencies/index.ts index df477f30..04a0ed31 100644 --- a/src/new-widgets/templatesDependencies/index.ts +++ b/src/new-widgets/templatesDependencies/index.ts @@ -19,29 +19,28 @@ import { RangeMixin } from './rangeMixin'; import { SetMixin } from './setMixin'; import { ValueRichtextMixin } from './valueRichtextMixin'; - /** * Template Depenedices Additions */ export { - AltMixin, - EditableMixin, - FilterRangeFormMixin, - FormCheckboxesMixin, - FormCheckboxMixin, - FormDropdownMixin, - FormFileMixin, - FormLengthMixin, - FormMinMaxMixin, - FormMixin, - FormNumberMixin, - FormRadioMixin, - FormStepMixin, - LinkTextMixin, - MultipleFormMixin, - MultipleselectFormMixin, - PatternMixin, - RangeMixin, - SetMixin, - ValueRichtextMixin -} + AltMixin, + EditableMixin, + FilterRangeFormMixin, + FormCheckboxesMixin, + FormCheckboxMixin, + FormDropdownMixin, + FormFileMixin, + FormLengthMixin, + FormMinMaxMixin, + FormMixin, + FormNumberMixin, + FormRadioMixin, + FormStepMixin, + LinkTextMixin, + MultipleFormMixin, + MultipleselectFormMixin, + PatternMixin, + RangeMixin, + SetMixin, + ValueRichtextMixin, +}; diff --git a/src/new-widgets/templatesDependencies/linkTextMixin.ts b/src/new-widgets/templatesDependencies/linkTextMixin.ts index dd8ad356..48bb6150 100644 --- a/src/new-widgets/templatesDependencies/linkTextMixin.ts +++ b/src/new-widgets/templatesDependencies/linkTextMixin.ts @@ -6,11 +6,9 @@ const LinkTextMixin = { default: '', callback: function (newValue: string) { this.addToAttributes(newValue, 'linkText'); - } + }, }, }, -} +}; -export { - LinkTextMixin -} \ No newline at end of file +export { LinkTextMixin }; diff --git a/src/new-widgets/templatesDependencies/multipleFormMixin.ts b/src/new-widgets/templatesDependencies/multipleFormMixin.ts index 161ac10f..8f301cd3 100644 --- a/src/new-widgets/templatesDependencies/multipleFormMixin.ts +++ b/src/new-widgets/templatesDependencies/multipleFormMixin.ts @@ -3,52 +3,58 @@ import { StoreMixin } from '../../mixins/storeMixin'; const MultipleFormMixin = { name: 'multiple-form-mixin', - use: [ StoreMixin ], + use: [StoreMixin], attributes: { widget: { type: String, - default: 'solid-form-text' + default: 'solid-form-text', }, addLabel: { type: String, default: '+', - callback: function(value) { - if (value !== this.listAttributes['addLabel']) this.listAttributes['addLabel'] = value; + callback: function (value) { + if (value !== this.listAttributes['addLabel']) + this.listAttributes['addLabel'] = value; this.planRender(); - } + }, }, removeLabel: { type: String, default: '×', - callback: function(value) { - if (value !== this.listAttributes['removeLabel']) this.listAttributes['removeLabel'] = value; + callback: function (value) { + if (value !== this.listAttributes['removeLabel']) + this.listAttributes['removeLabel'] = value; this.planRender(); - } + }, }, range: { type: String, default: '', - }, addClass: { type: String, default: undefined, - callback: function(value) { - if (value !== this.listAttributes['addClass']) this.listAttributes['addClass'] = value; + callback: function (value) { + if (value !== this.listAttributes['addClass']) + this.listAttributes['addClass'] = value; this.planRender(); - } + }, }, removeClass: { type: String, default: undefined, - callback: function(value) { - if (value !== this.listAttributes['removeClass']) this.listAttributes['removeClass'] = value; + callback: function (value) { + if (value !== this.listAttributes['removeClass']) + this.listAttributes['removeClass'] = value; this.planRender(); - } - } + }, + }, }, created() { - this.listValueTransformations.attach(this.setDataSrc.bind(this), "MultipleFormMixin:setDataSrc"); + this.listValueTransformations.attach( + this.setDataSrc.bind(this), + 'MultipleFormMixin:setDataSrc', + ); this.listAttributes['children'] = []; this.listAttributes['addLabel'] = this.addLabel; @@ -59,9 +65,11 @@ const MultipleFormMixin = { this.insertWidget(); this.planRender(); }; - this.listAttributes['removeItem'] = (index) => { - this.element.querySelector(`[data-index="${this.name + index}"]`).remove(); - this.element.dispatchEvent(new Event('change', {bubbles: true})); + this.listAttributes['removeItem'] = index => { + this.element + .querySelector(`[data-index="${this.name + index}"]`) + .remove(); + this.element.dispatchEvent(new Event('change', { bubbles: true })); }; }, setDataSrc(value: string, listValueTransformations: PostProcessorRegistry) { @@ -85,7 +93,8 @@ const MultipleFormMixin = { this.listAttributes['children'] = []; // reset list // set value in form - for (let resource of this.resource['ldp:contains']) { // for each resource + for (let resource of this.resource['ldp:contains']) { + // for each resource this.insertWidget(resource['@id']); // create a widget } this.planRender(); @@ -95,12 +104,13 @@ const MultipleFormMixin = { const widget = document.createElement(this.widget); const attributes = { 'data-holder': true, - 'name': this.name, - 'value': value, - 'range': this.range + name: this.name, + value: value, + range: this.range, }; for (let name of Object.keys(attributes)) { - if (typeof attributes[name] === "boolean") widget.toggleAttribute(name, attributes[name]); + if (typeof attributes[name] === 'boolean') + widget.toggleAttribute(name, attributes[name]); else widget.setAttribute(name, attributes[name]); } this.listAttributes['children'].push(widget); @@ -123,10 +133,7 @@ const MultipleFormMixin = { }, get multiple() { return true; - } - -} + }, +}; -export { - MultipleFormMixin -} \ No newline at end of file +export { MultipleFormMixin }; diff --git a/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts b/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts index 5c067b3d..154a6c6d 100644 --- a/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts +++ b/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts @@ -3,39 +3,46 @@ import { StoreMixin } from '../../mixins/storeMixin'; const MultipleselectFormMixin = { name: 'multipleselect-form-mixin', - use: [ StoreMixin ], + use: [StoreMixin], attributes: { - range: { // range attribute is passed to the solid-dropdown + range: { + // range attribute is passed to the solid-dropdown type: String, default: '', - callback: function(value) { - if (value && value !== this.listAttributes['range']) this.listAttributes['range'] = value; - } + callback: function (value) { + if (value && value !== this.listAttributes['range']) + this.listAttributes['range'] = value; + }, }, - enum: { // enum attribute is passed to the solid-dropdown + enum: { + // enum attribute is passed to the solid-dropdown type: String, default: '', callback: function (value) { - if (value && value !== this.listAttributes['enum']) this.listAttributes['enum'] = value; - } + if (value && value !== this.listAttributes['enum']) + this.listAttributes['enum'] = value; + }, }, orderAsc: { type: String, default: 'name', callback: function (newValue: string) { this.addToAttributes(newValue, 'orderAsc'); - } + }, }, orderDesc: { type: String, default: 'name', callback: function (newValue: string) { this.addToAttributes(newValue, 'orderDesc'); - } - } + }, + }, }, created() { - this.listValueTransformations.attach(this.setDataSrc.bind(this), "MultipleselectFormMixin:setDataSrc"); + this.listValueTransformations.attach( + this.setDataSrc.bind(this), + 'MultipleselectFormMixin:setDataSrc', + ); }, setDataSrc(value: string, listValueTransformations: PostProcessorRegistry) { if (value && value !== this.dataSrc) { @@ -48,15 +55,19 @@ const MultipleselectFormMixin = { } } catch (ex) { this.dataSrc = value; - this.setValue([ {"@id": value}]); + this.setValue([{ '@id': value }]); } } const nextProcessor = listValueTransformations.shift(); - if(nextProcessor) nextProcessor(value, listValueTransformations); + if (nextProcessor) nextProcessor(value, listValueTransformations); }, populate() { - if (!this.resource || (!this.resource['ldp:contains'] && !Array.isArray(this.resource))) return; + if ( + !this.resource || + (!this.resource['ldp:contains'] && !Array.isArray(this.resource)) + ) + return; this.setValue(this.resource['ldp:contains']); // TODO: Rationalize or clean this commented code @@ -66,7 +77,8 @@ const MultipleselectFormMixin = { this.planRender(); }, - setValue(values: string[]) { // set the values to the dropdown + setValue(values: string[]) { + // set the values to the dropdown this.listAttributes['values'] = JSON.stringify(values.map(r => r['@id'])); }, empty() { @@ -79,8 +91,6 @@ const MultipleselectFormMixin = { get multiple() { return true; }, -} +}; -export { - MultipleselectFormMixin -} \ No newline at end of file +export { MultipleselectFormMixin }; diff --git a/src/new-widgets/templatesDependencies/patternMixin.ts b/src/new-widgets/templatesDependencies/patternMixin.ts index b2748ff9..e9f4944f 100644 --- a/src/new-widgets/templatesDependencies/patternMixin.ts +++ b/src/new-widgets/templatesDependencies/patternMixin.ts @@ -1,21 +1,19 @@ const PatternMixin = { name: 'pattern-mixin', - attributes : { - pattern : { + attributes: { + pattern: { type: String, callback: function (newValue: string) { - this.addToAttributes(newValue, 'pattern') - } + this.addToAttributes(newValue, 'pattern'); + }, }, - title : { + title: { type: String, callback: function (newValue: string) { this.addToAttributes(newValue, 'title'); - } + }, }, }, -} +}; -export { - PatternMixin -} \ No newline at end of file +export { PatternMixin }; diff --git a/src/new-widgets/templatesDependencies/rangeMixin.ts b/src/new-widgets/templatesDependencies/rangeMixin.ts index d068d9d5..40da95e9 100644 --- a/src/new-widgets/templatesDependencies/rangeMixin.ts +++ b/src/new-widgets/templatesDependencies/rangeMixin.ts @@ -7,32 +7,28 @@ import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const RangeMixin = { name: 'range-mixin', - use: [ - StoreMixin, - SorterMixin, - FederationMixin - ], + use: [StoreMixin, SorterMixin, FederationMixin], attributes: { range: { type: String, default: '', callback: function (value: string) { if (value !== this.dataSrc) this.dataSrc = value; - } + }, }, enum: { type: String, default: '', callback: function (value: string) { if (value !== null) { - const optional = value.trim().split(","); + const optional = value.trim().split(','); let key; let keyValue; const list = {}; optional.forEach(element => { - if (element.includes("=")) { - const option = element.trim().split("="); + if (element.includes('=')) { + const option = element.trim().split('='); key = option[1].trim(); keyValue = option[0].trim(); list[key] = keyValue; @@ -42,23 +38,23 @@ const RangeMixin = { } }); this.addToAttributes(list, 'enum'); - }; - } + } + }, }, optionLabel: { type: String, default: 'name', callback: function (newValue: string) { this.addToAttributes(newValue, 'optionLabel'); - } + }, }, optionValue: { type: String, default: '@id', callback: function (newValue: string) { this.addToAttributes(newValue, 'optionValue'); - } - } + }, + }, }, initialState: { listPostProcessors: new PostProcessorRegistry(), @@ -71,23 +67,22 @@ const RangeMixin = { async populate() { const resources = this.resource ? this.resource['ldp:contains'] : []; const listPostProcessorsCopy = this.listPostProcessors.deepCopy(); - listPostProcessorsCopy.attach(this.setRangeAttribute.bind(this), 'RangeMixin:setRangeAttribute'); + listPostProcessorsCopy.attach( + this.setRangeAttribute.bind(this), + 'RangeMixin:setRangeAttribute', + ); const nextProcessor = listPostProcessorsCopy.shift(); - await nextProcessor( - resources, - listPostProcessorsCopy, - null, - this.dataSrc, - ); + await nextProcessor(resources, listPostProcessorsCopy, null, this.dataSrc); }, - async setRangeAttribute( - resources: Resource[] - ) { + async setRangeAttribute(resources: Resource[]) { if (resources) { // process resources to create the template const getRangeValue = async (resource: Resource) => { - let res = await store.getData(resource['@id'], this.context || base_context); + let res = await store.getData( + resource['@id'], + this.context || base_context, + ); //TODO: handle properly the fact that the res could be null if (res === null) { res = resource; @@ -95,18 +90,20 @@ const RangeMixin = { //TODO: this splitting and expanding is disgusting, please find another solution !! const selectedValue = await resource[this.optionValue]; // value used for selected options - const value = (this.optionValue.includes('@id') || selectedValue['@id']) ? - `{"@id": "${selectedValue}"}` : // resource - selectedValue; // literal + const value = + this.optionValue.includes('@id') || selectedValue['@id'] + ? `{"@id": "${selectedValue}"}` + : // resource + selectedValue; // literal //TODO: this splitting and expanding is disgusting, please find another solution !! - let labelProperty = this.optionLabel.split(/[.]+/).pop() + let labelProperty = this.optionLabel.split(/[.]+/).pop(); const label = await res[labelProperty]; // label of the option - return { value, label, selectedValue } - } + return { value, label, selectedValue }; + }; this.listAttributes['range'] = await Promise.all( - resources.filter(el => el !== null).map(r => getRangeValue(r)) + resources.filter(el => el !== null).map(r => getRangeValue(r)), ); } @@ -117,10 +114,8 @@ const RangeMixin = { this.planRender(); }, get type() { - return this.enum === ''? 'resource' : 'string'; - } -} + return this.enum === '' ? 'resource' : 'string'; + }, +}; -export { - RangeMixin -} \ No newline at end of file +export { RangeMixin }; diff --git a/src/new-widgets/templatesDependencies/setMixin.ts b/src/new-widgets/templatesDependencies/setMixin.ts index 4505df53..712472d8 100644 --- a/src/new-widgets/templatesDependencies/setMixin.ts +++ b/src/new-widgets/templatesDependencies/setMixin.ts @@ -4,9 +4,7 @@ const SetMixin = { * For sets and group widgets, remove auto rendering * function to allow only manual renders */ - planRender() { }, -} + planRender() {}, +}; -export { - SetMixin -} \ No newline at end of file +export { SetMixin }; diff --git a/src/new-widgets/templatesDependencies/valueRichtextMixin.ts b/src/new-widgets/templatesDependencies/valueRichtextMixin.ts index 740a12ae..c1389df4 100644 --- a/src/new-widgets/templatesDependencies/valueRichtextMixin.ts +++ b/src/new-widgets/templatesDependencies/valueRichtextMixin.ts @@ -1,13 +1,11 @@ import qdtm from 'quill-delta-to-markdown'; const ValueRichtextMixin = { name: 'valuerichtext-mixin', - + getValue() { const markdown = qdtm.deltaToMarkdown(this.quill.getContents().ops); return markdown; }, -} +}; -export { - ValueRichtextMixin -} \ No newline at end of file +export { ValueRichtextMixin }; diff --git a/src/new-widgets/valueTransformationMixins/autolinkMixin.ts b/src/new-widgets/valueTransformationMixins/autolinkMixin.ts index 27726bd7..351aead1 100644 --- a/src/new-widgets/valueTransformationMixins/autolinkMixin.ts +++ b/src/new-widgets/valueTransformationMixins/autolinkMixin.ts @@ -1,17 +1,24 @@ -import {Autolinker} from 'autolinker'; +import { Autolinker } from 'autolinker'; import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const AutolinkMixin = { name: 'autolink-mixin', created() { - this.listValueTransformations.attach(this.transformValue.bind(this), "AutolinkMixin:transformValue"); + this.listValueTransformations.attach( + this.transformValue.bind(this), + 'AutolinkMixin:transformValue', + ); }, - transformValue(value: string, listValueTransformations: PostProcessorRegistry) { + transformValue( + value: string, + listValueTransformations: PostProcessorRegistry, + ) { const template = document.createElement('template'); - template.innerHTML = Autolinker.link(value); + template.innerHTML = Autolinker.link(value); const nextProcessor = listValueTransformations.shift(); - if (nextProcessor) nextProcessor(template.content, listValueTransformations); + if (nextProcessor) + nextProcessor(template.content, listValueTransformations); }, }; diff --git a/src/new-widgets/valueTransformationMixins/dateMixin.ts b/src/new-widgets/valueTransformationMixins/dateMixin.ts index d1a8a8cb..5f690c4c 100644 --- a/src/new-widgets/valueTransformationMixins/dateMixin.ts +++ b/src/new-widgets/valueTransformationMixins/dateMixin.ts @@ -1,11 +1,17 @@ -import { PostProcessorRegistry } from "../../libs/PostProcessorRegistry"; +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const DateMixin = { name: 'date-mixin', created() { - this.listValueTransformations.attach(this.transformValue.bind(this), "DateMixin:transformValue"); + this.listValueTransformations.attach( + this.transformValue.bind(this), + 'DateMixin:transformValue', + ); }, - transformValue(value: string, listValueTransformations: PostProcessorRegistry) { + transformValue( + value: string, + listValueTransformations: PostProcessorRegistry, + ) { try { // workaround for giving a specific-formatted value to the form widget this.listAttributes['originalValue'] = this.formatDateForInput(value); @@ -16,7 +22,7 @@ const DateMixin = { const newValue = value ? new Date(value).toLocaleDateString() : value; const nextProcessor = listValueTransformations.shift(); - if(nextProcessor) nextProcessor(newValue, listValueTransformations); + if (nextProcessor) nextProcessor(newValue, listValueTransformations); }, formatDateForInput(date: string) { let d = new Date(date); @@ -29,9 +35,7 @@ const DateMixin = { if (day.length < 2) day = `0${day}`; return [year, month, day].join('-'); - } -} + }, +}; -export { - DateMixin -} \ No newline at end of file +export { DateMixin }; diff --git a/src/new-widgets/valueTransformationMixins/dateTimeMixin.ts b/src/new-widgets/valueTransformationMixins/dateTimeMixin.ts index 49407051..68e28202 100644 --- a/src/new-widgets/valueTransformationMixins/dateTimeMixin.ts +++ b/src/new-widgets/valueTransformationMixins/dateTimeMixin.ts @@ -1,18 +1,22 @@ -import { PostProcessorRegistry } from "../../libs/PostProcessorRegistry"; +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const DateTimeMixin = { name: 'date-time-mixin', created() { - this.listValueTransformations.attach(this.transformValue.bind(this), "DateTimeMixin:transformValue"); + this.listValueTransformations.attach( + this.transformValue.bind(this), + 'DateTimeMixin:transformValue', + ); }, - transformValue(value: string, listValueTransformations: PostProcessorRegistry) { + transformValue( + value: string, + listValueTransformations: PostProcessorRegistry, + ) { const newValue = value ? new Date(value).toLocaleString() : value; const nextProcessor = listValueTransformations.shift(); - if(nextProcessor) nextProcessor(newValue, listValueTransformations); - } -} + if (nextProcessor) nextProcessor(newValue, listValueTransformations); + }, +}; -export { - DateTimeMixin -} \ No newline at end of file +export { DateTimeMixin }; diff --git a/src/new-widgets/valueTransformationMixins/index.ts b/src/new-widgets/valueTransformationMixins/index.ts index eeabf92a..af40ff7a 100644 --- a/src/new-widgets/valueTransformationMixins/index.ts +++ b/src/new-widgets/valueTransformationMixins/index.ts @@ -11,8 +11,8 @@ const valueTransformationDirectory = { multiline: MultilineMixin, markdown: MarkdownMixin, oembed: OembedMixin, - autolink: AutolinkMixin -} + autolink: AutolinkMixin, +}; export { valueTransformationDirectory, @@ -21,5 +21,5 @@ export { MultilineMixin, MarkdownMixin, OembedMixin, - AutolinkMixin -} + AutolinkMixin, +}; diff --git a/src/new-widgets/valueTransformationMixins/markdownMixin.ts b/src/new-widgets/valueTransformationMixins/markdownMixin.ts index 401f93f5..1d369565 100644 --- a/src/new-widgets/valueTransformationMixins/markdownMixin.ts +++ b/src/new-widgets/valueTransformationMixins/markdownMixin.ts @@ -7,9 +7,15 @@ import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const MarkdownMixin = { name: 'markdown-mixin', created() { - this.listValueTransformations.attach(this.transformValue.bind(this), "MarkdownMixin:transformValue"); + this.listValueTransformations.attach( + this.transformValue.bind(this), + 'MarkdownMixin:transformValue', + ); }, - transformValue(value: string, listValueTransformations: PostProcessorRegistry) { + transformValue( + value: string, + listValueTransformations: PostProcessorRegistry, + ) { let newValue: any = ''; if (value) { const md = markdownit({ @@ -22,7 +28,7 @@ const MarkdownMixin = { attrs: { target: '_blank', rel: 'noopener', - } + }, }); const html = md.render(value); @@ -31,9 +37,7 @@ const MarkdownMixin = { const nextProcessor = listValueTransformations.shift(); if (nextProcessor) nextProcessor(newValue, listValueTransformations); - } -} + }, +}; -export { - MarkdownMixin -} \ No newline at end of file +export { MarkdownMixin }; diff --git a/src/new-widgets/valueTransformationMixins/multilineMixin.ts b/src/new-widgets/valueTransformationMixins/multilineMixin.ts index 6e80e03a..2072f114 100644 --- a/src/new-widgets/valueTransformationMixins/multilineMixin.ts +++ b/src/new-widgets/valueTransformationMixins/multilineMixin.ts @@ -4,16 +4,20 @@ import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const MultilineMixin = { name: 'multiline-mixin', created() { - this.listValueTransformations.attach(this.transformValue.bind(this), "MultilineMixin:transformValue"); + this.listValueTransformations.attach( + this.transformValue.bind(this), + 'MultilineMixin:transformValue', + ); }, - transformValue(value: string, listValueTransformations: PostProcessorRegistry) { - const newValue = value ? unsafeHTML(value.replace(/\n/g, "<br/>")) : value; + transformValue( + value: string, + listValueTransformations: PostProcessorRegistry, + ) { + const newValue = value ? unsafeHTML(value.replace(/\n/g, '<br/>')) : value; const nextProcessor = listValueTransformations.shift(); if (nextProcessor) nextProcessor(newValue, listValueTransformations); - } -} + }, +}; -export { - MultilineMixin -} \ No newline at end of file +export { MultilineMixin }; diff --git a/src/new-widgets/valueTransformationMixins/oembedMixin.ts b/src/new-widgets/valueTransformationMixins/oembedMixin.ts index 8bda9c17..eb44fb7d 100644 --- a/src/new-widgets/valueTransformationMixins/oembedMixin.ts +++ b/src/new-widgets/valueTransformationMixins/oembedMixin.ts @@ -3,25 +3,29 @@ import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const OembedMixin = { name: 'oembed-mixin', - initialState : { + initialState: { existingOembed: null, }, created(): void { - this.listValueTransformations.attach(this.transformValue.bind(this), "OembedMixin:transformValue"); + this.listValueTransformations.attach( + this.transformValue.bind(this), + 'OembedMixin:transformValue', + ); }, - async transformValue(value: string, listValueTransformations: PostProcessorRegistry) { + async transformValue( + value: string, + listValueTransformations: PostProcessorRegistry, + ) { if (!value) return; if (this.existingOembed == null) { const response = await fetch(this.value); this.existingOembed = await response.json(); } const newValue = unsafeHTML(this.existingOembed.html); - + const nextProcessor = listValueTransformations.shift(); if (nextProcessor) nextProcessor(newValue, listValueTransformations); - } -} + }, +}; -export { - OembedMixin -} \ No newline at end of file +export { OembedMixin }; diff --git a/src/solid-template-element.ts b/src/solid-template-element.ts index 61302908..f427c5ad 100644 --- a/src/solid-template-element.ts +++ b/src/solid-template-element.ts @@ -5,7 +5,7 @@ export default class SolidTemplateElement extends HTMLElement { strings = {}; translationsPath = null; translationsFetched = false; - props : {[key:string]:any} = {} + props: { [key: string]: any } = {}; constructor() { super(); this.initProps(); @@ -14,14 +14,13 @@ export default class SolidTemplateElement extends HTMLElement { return Object.values(this.propsDefinition); } - static get propsDefinition():{[key:string]:any} { - return { - }; + static get propsDefinition(): { [key: string]: any } { + return {}; } initProps() { - this.props = {} - for(let key in this.constructor.propsDefinition) { + this.props = {}; + for (let key in this.constructor.propsDefinition) { this.props[key] = undefined; } } @@ -30,20 +29,29 @@ export default class SolidTemplateElement extends HTMLElement { const declaredAttributes: string[] = []; // Get props values - for(let key in this.constructor.propsDefinition) { + for (let key in this.constructor.propsDefinition) { const def = this.constructor.propsDefinition[key]; - if (typeof def === "string") { - this.props[key] = this.hasAttribute(def) ? this.getAttribute(def) : undefined; + if (typeof def === 'string') { + this.props[key] = this.hasAttribute(def) + ? this.getAttribute(def) + : undefined; declaredAttributes.push(def); - } else if (typeof def === "object" && def.attribute && typeof def.attribute === "string") { - this.props[key] = this.hasAttribute(def.attribute) ? this.getAttribute(def.attribute) : def.default || undefined; + } else if ( + typeof def === 'object' && + def.attribute && + typeof def.attribute === 'string' + ) { + this.props[key] = this.hasAttribute(def.attribute) + ? this.getAttribute(def.attribute) + : def.default || undefined; declaredAttributes.push(def.attribute); } } // Add attributes to props for (let attr of this.attributes) { - if (!declaredAttributes.includes(attr.name)) { // if attribute not in propsDefinition + if (!declaredAttributes.includes(attr.name)) { + // if attribute not in propsDefinition this.props[this._camelize(attr.name)] = attr.value || undefined; // add it to props } } @@ -62,19 +70,21 @@ export default class SolidTemplateElement extends HTMLElement { */ async fetchLocaleStrings() { if (this.translationsFetched) return; - const filesToFetch:any[] = []; - if (this.translationsPath) // fetch component translations + const filesToFetch: any[] = []; + if (this.translationsPath) + // fetch component translations filesToFetch.push(this.fetchTranslationFile(this.translationsPath)); const extraTranslationsPath = this.getAttribute('extra-translations-path'); - if (extraTranslationsPath) // fetch developer translations + if (extraTranslationsPath) + // fetch developer translations filesToFetch.push(this.fetchTranslationFile(extraTranslationsPath)); // merge all translations return Promise.all(filesToFetch).then(res => { this.translationsFetched = true; this.strings = Object.assign({}, ...res); - }) + }); } /** @@ -84,19 +94,31 @@ export default class SolidTemplateElement extends HTMLElement { const ln = this.getLocale(); const fullPath = `${path}/${ln}.json`; return fetch(fullPath) - .then((result) => { + .then(result => { if (result.ok) { - return result.json() // parse content - .catch(e => console.error(`Error while parsing the translation file: ${fullPath}`)); + return result + .json() // parse content + .catch(e => + console.error( + `Error while parsing the translation file: ${fullPath}`, + ), + ); } - }).catch(e => console.error(`Error while retrieving the translation file: ${fullPath}`)); + }) + .catch(e => + console.error( + `Error while retrieving the translation file: ${fullPath}`, + ), + ); } /** * Returns current locale of app */ getLocale() { - return localStorage.getItem('language') || window.navigator.language.slice(0, 2); + return ( + localStorage.getItem('language') || window.navigator.language.slice(0, 2) + ); } /** @@ -107,8 +129,7 @@ export default class SolidTemplateElement extends HTMLElement { return this.strings[key] || key; } - attributeChangedCallback() - { + attributeChangedCallback() { this.updateProps(); this.planRender(); } @@ -131,10 +152,11 @@ export default class SolidTemplateElement extends HTMLElement { } } - renderCallback() { } + renderCallback() {} render() { - this.fetchLocaleStrings().finally(() => { // render even if some errors occurred + this.fetchLocaleStrings().finally(() => { + // render even if some errors occurred this.innerHTML = this.template(this.props); this.renderCallback(); }); diff --git a/src/store.d.ts b/src/store.d.ts index 53e696f5..72f0fdcb 100644 --- a/src/store.d.ts +++ b/src/store.d.ts @@ -1,6 +1,6 @@ declare var sibStore: any; interface StoreOptions { - fetchMethod?: Promise<any> - session?: Promise<any> + fetchMethod?: Promise<any>; + session?: Promise<any>; } diff --git a/src/style/default-theme.css b/src/style/default-theme.css index da97c874..3f38477d 100644 --- a/src/style/default-theme.css +++ b/src/style/default-theme.css @@ -12,7 +12,7 @@ } .sib-custom-marker::after { position: absolute; - content: ''; + content: ""; width: 0px; height: 0px; bottom: -30px; @@ -21,4 +21,4 @@ border-top-width: 17px; border-top-style: solid; border-top-color: inherit; -} \ No newline at end of file +} diff --git a/src/widgets/baseWidget.ts b/src/widgets/baseWidget.ts index 1f0a0c03..1f988fc0 100644 --- a/src/widgets/baseWidget.ts +++ b/src/widgets/baseWidget.ts @@ -16,9 +16,9 @@ export class BaseWidget extends HTMLElement { this.render(); } disconnectedCallback(): void { - this._subscriptions.forEach((subscription) => { + this._subscriptions.forEach(subscription => { PubSub.unsubscribe(subscription); - }) + }); } async render() { this.innerHTML = await evalTemplateString(this.template, { @@ -32,7 +32,7 @@ export class BaseWidget extends HTMLElement { range: await this.htmlRange, multiple: this.multiple, editable: this.editable === '' ? true : false, - required: this.required === '' ? true : false + required: this.required === '' ? true : false, }); this.addEditButtons(); @@ -42,27 +42,30 @@ export class BaseWidget extends HTMLElement { return this.hasAttribute('label') ? this.getAttribute('label') : this.name; } set label(label: string | null) { - if(label != null) this.setAttribute('label', label); + if (label != null) this.setAttribute('label', label); this.render(); } get placeholder(): string | null { - return this.hasAttribute('placeholder') ? this.getAttribute('placeholder') : this.label; + return this.hasAttribute('placeholder') + ? this.getAttribute('placeholder') + : this.label; } set placeholder(placeholder: string | null) { - if(placeholder != null) this.setAttribute('placeholder', placeholder); + if (placeholder != null) this.setAttribute('placeholder', placeholder); this.render(); } get name(): string | null { return this.getAttribute('name'); } set name(name: string | null) { - if(name) this.setAttribute('name', name); + if (name) this.setAttribute('name', name); this.render(); } get value() { if (this.dataHolder) { let values = this.dataHolder.map(element => { - if (element instanceof HTMLInputElement && element.type == "checkbox") return element.checked; + if (element instanceof HTMLInputElement && element.type == 'checkbox') + return element.checked; // if value is defined, push it in the array return this.getValueHolder(element).value; }); @@ -78,7 +81,7 @@ export class BaseWidget extends HTMLElement { if (this.dataHolder && this.dataHolder.length === 1) { // if one dataHolder in the widget... const element = this.getValueHolder(this.dataHolder[0]); - if (element.type == "checkbox") { + if (element.type == 'checkbox') { element.checked = value; } else { element.value = value; // ... set `value` to the dataHolder element @@ -87,22 +90,20 @@ export class BaseWidget extends HTMLElement { if (element.dispatchEvent) element.dispatchEvent(new Event('change')); // trigger change manually } else if (this.dataHolder && this.dataHolder.length > 1) { // if multiple dataHolder in the widget ... - this.dataHolder.forEach( - (el, index) => { - const element = this.getValueHolder(el); - if (element.type == "checkbox") { - element.checked = value ? value[index] : '' - } else { - element.value = value ? value[index] : '' - } - element.dispatchEvent(new Event('change')); // trigger change manually - }, - ); // ... set each `value` to each dataHolder element + this.dataHolder.forEach((el, index) => { + const element = this.getValueHolder(el); + if (element.type == 'checkbox') { + element.checked = value ? value[index] : ''; + } else { + element.value = value ? value[index] : ''; + } + element.dispatchEvent(new Event('change')); // trigger change manually + }); // ... set each `value` to each dataHolder element } this.render(); } - get ['each-label'](): string{ + get ['each-label'](): string { return this.getAttribute('each-label') || ''; } set ['each-label'](label: string) { @@ -115,10 +116,18 @@ export class BaseWidget extends HTMLElement { this.setAttribute('remove-label', label); } get dataHolder(): Element[] | null { - const widgetDataHolders = Array.from(this.querySelectorAll('[data-holder]')).filter(element => { - const dataHolderAncestor = element.parentElement ? element.parentElement.closest('[data-holder]') : null; + const widgetDataHolders = Array.from( + this.querySelectorAll('[data-holder]'), + ).filter(element => { + const dataHolderAncestor = element.parentElement + ? element.parentElement.closest('[data-holder]') + : null; // get the dataHolder of the widget only if no dataHolder ancestor in the current widget - return dataHolderAncestor === this || !dataHolderAncestor || !this.contains(dataHolderAncestor) + return ( + dataHolderAncestor === this || + !dataHolderAncestor || + !this.contains(dataHolderAncestor) + ); }); return widgetDataHolders.length ? widgetDataHolders : null; @@ -147,7 +156,10 @@ export class BaseWidget extends HTMLElement { } set range(range) { (async () => { - this._listen(range, async () => this._range = await store.getData(range, this.context)); + this._listen( + range, + async () => (this._range = await store.getData(range, this.context)), + ); this._range = await store.getData(range, this.context); this.render(); })(); @@ -157,16 +169,24 @@ export class BaseWidget extends HTMLElement { let resources: any[] = []; let index = 0; for (let res of resource['ldp:contains']) { - if (!res) { // child not in cache yet + if (!res) { + // child not in cache yet try { const resourceId = resource.getChildren('ldp:contains')[index]['@id']; - res = await store.getData(resourceId, this.context) - } catch (e) { continue; } + res = await store.getData(resourceId, this.context); + } catch (e) { + continue; + } } - if (res.isContainer?.()) { // if nested container - let resourcesFromContainer = await store.getData(res['@id'], this.context); // fetch the datas + if (res.isContainer?.()) { + // if nested container + let resourcesFromContainer = await store.getData( + res['@id'], + this.context, + ); // fetch the datas this._listen(res['@id']); - if (resourcesFromContainer) resources.push(...resourcesFromContainer['ldp:contains']); + if (resourcesFromContainer) + resources.push(...resourcesFromContainer['ldp:contains']); } else { resources.push(res); } @@ -185,21 +205,27 @@ export class BaseWidget extends HTMLElement { this._listen(element['@id']); let selected: boolean; - if (this._value && this._value.isContainer && this._value.isContainer()) { // selected options for multiple select + if ( + this._value && + this._value.isContainer && + this._value.isContainer() + ) { + // selected options for multiple select selected = false; - for await (let value of this._value["ldp:contains"]) { + for await (let value of this._value['ldp:contains']) { if (value['@id'] == element['@id']) { selected = true; break; } } - } else { // selected options for simple dropdowns + } else { + // selected options for simple dropdowns selected = this._value ? this._value['@id'] == element['@id'] : false; } htmlRange += await evalTemplateString(this.childTemplate, { name: await element.name, id: element['@id'], - selected: selected + selected: selected, }); } return htmlRange || ''; @@ -215,10 +241,13 @@ export class BaseWidget extends HTMLElement { _listen(id: string, callback: Function = () => {}) { if (!this._subscriptions.get(id)) { - this._subscriptions.set(id, PubSub.subscribe(id, async () => { - await callback(); - this.render(); - })) + this._subscriptions.set( + id, + PubSub.subscribe(id, async () => { + await callback(); + this.render(); + }), + ); } } @@ -229,18 +258,24 @@ export class BaseWidget extends HTMLElement { if (editableField) { // Add edit button const editButton = document.createElement('button'); - editButton.innerText = "Modifier"; - editButton.onclick = () => this.activateEditableField(editableField, editButton); + editButton.innerText = 'Modifier'; + editButton.onclick = () => + this.activateEditableField(editableField, editButton); editableField.insertAdjacentElement('afterend', editButton); // Save on focusout - editableField.addEventListener('focusout', () => this.save(editableField, editButton)); + editableField.addEventListener('focusout', () => + this.save(editableField, editButton), + ); } } - activateEditableField(editableField: HTMLElement, editButton: HTMLButtonElement): void { + activateEditableField( + editableField: HTMLElement, + editButton: HTMLButtonElement, + ): void { editableField.setAttribute('contenteditable', 'true'); editableField.focus(); - editButton.setAttribute("disabled", "disabled"); + editButton.setAttribute('disabled', 'disabled'); } /** * Dispatch change events of data holders from the current widget @@ -259,13 +294,13 @@ export class BaseWidget extends HTMLElement { } save(editableField: HTMLElement, editButton: HTMLButtonElement): void { editableField.setAttribute('contenteditable', 'false'); - editButton.removeAttribute("disabled"); + editButton.removeAttribute('disabled'); if (!this.name) return; const resource = {}; resource[this.name] = editableField.innerText; resource['@context'] = this.context; - if(this.resourceId && resource) store.patch(resource, this.resourceId) + if (this.resourceId && resource) store.patch(resource, this.resourceId); } } diff --git a/src/window.d.ts b/src/window.d.ts index cbc4eb28..783e1ea9 100644 --- a/src/window.d.ts +++ b/src/window.d.ts @@ -3,7 +3,7 @@ declare var markdownit: any; declare var fetchTranslationPromise: Promise; declare var cachePropsSearchFilter: { [key: string]: { - setFields: string[] | null - setSearchFields: string[] | null - } + setFields: string[] | null; + setSearchFields: string[] | null; + }; }; diff --git a/vite.config.ts b/vite.config.ts index deb78a86..e7f799de 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -12,10 +12,7 @@ export default defineConfig({ }, rollupOptions: { preserveEntrySignatures: 'strict', - input: [ - './src/index.ts', - './src/libs/helpers.ts', - ], + input: ['./src/index.ts', './src/libs/helpers.ts'], output: { dir: 'dist', entryFileNames: '[name].js', @@ -23,6 +20,6 @@ export default defineConfig({ }, outDir: 'dist', minify: false, - reportCompressedSize:false, + reportCompressedSize: false, }, }); -- GitLab From 6d6229c7c6a502226bc5c5d38b18179df9df13c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Wed, 20 Nov 2024 17:11:14 +0100 Subject: [PATCH 27/66] bugfix: #883 tests fail locally --- cypress/e2e/e2e/solid-form-richtext.cy.ts | 8 +++---- package-lock.json | 14 ++++++------ server.js | 27 ++++++++++++++--------- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/cypress/e2e/e2e/solid-form-richtext.cy.ts b/cypress/e2e/e2e/solid-form-richtext.cy.ts index 430b07f0..e9f6fd83 100644 --- a/cypress/e2e/e2e/solid-form-richtext.cy.ts +++ b/cypress/e2e/e2e/solid-form-richtext.cy.ts @@ -10,8 +10,8 @@ describe('solid-form-richtext test', function () { cy.get('#form-1 div[data-richtext] .error-border-richtext').should('not.exist'); }); - it('Submitting form with empty rich text input should display an error mesage', () => { - cy.get('#form-1 div[data-richtext] p').clear(); + it('Submitting form with empty rich text input should display an error message', () => { + cy.get('#form-1 div[data-richtext] [contenteditable]').should('have.text', 'some description').clear(); cy.get('#form-1 input[type="submit"]').click(); cy.get('#form-1 div[data-richtext] .required-error-message').should('exist'); cy.get('#form-1 div[data-richtext].error-border-richtext').should('exist'); @@ -19,12 +19,12 @@ describe('solid-form-richtext test', function () { it('Error message disappears when retyping in rich text input', () => { // Empty fields , error is shown - cy.get('#form-1 div[data-richtext] p').clear(); + cy.get('#form-1 div[data-richtext] [contenteditable]').should('have.text', 'some description').clear(); cy.get('#form-1 input[type="submit"]').click(); cy.get('#form-1 div[data-richtext] .required-error-message').should('exist'); cy.get('#form-1 div[data-richtext].error-border-richtext').should('exist'); - // Retype text , error disapears + // Retype text , error disappears cy.get('#form-1 div[data-richtext] p').type('some text'); cy.get('#form-1 input[type="submit"]').click(); cy.get('#form-1 div[data-richtext] .required-error-message').should('not.exist'); diff --git a/package-lock.json b/package-lock.json index 7668eaaf..2888b4bd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1486,9 +1486,9 @@ } }, "node_modules/cookie": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", - "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", + "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", "dev": true, "license": "MIT", "engines": { @@ -2092,9 +2092,9 @@ } }, "node_modules/express": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/express/-/express-4.21.0.tgz", - "integrity": "sha512-VqcNGcj/Id5ZT1LZ/cfihi3ttTn+NJmkli2eZADigjq29qTlWi/hAQ43t/VLPq8+UX06FCEx3ByOYet6ZFblng==", + "version": "4.21.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", + "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", "dev": true, "license": "MIT", "dependencies": { @@ -2103,7 +2103,7 @@ "body-parser": "1.20.3", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.6.0", + "cookie": "0.7.1", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", diff --git a/server.js b/server.js index 3f08c387..631e0016 100644 --- a/server.js +++ b/server.js @@ -1,3 +1,5 @@ +// @ts-check + import crypto from 'crypto'; import cypress from 'cypress'; import url from 'url'; @@ -9,14 +11,15 @@ import cors from 'cors'; const port = findFreePort(3000); const app = express(); const distPath = '.'; - app.use(cors()); +// Set the browser language to English to ensure consistent test conditions. +process.env.ELECTRON_EXTRA_LAUNCH_ARGS = '--lang=en'; (async () => { const updateURLs = /.*jsonld/; const server = app .use(express.static(distPath)) .use(express.json({ type: 'application/*+json' })) - .get('/favicon.ico', (req, rep) => rep.send()) + .get('/favicon.ico', (_req, rep) => void rep.send()) // Handle upload .post('/upload', (req, rep) => { const originalUrl = url.format({ @@ -33,7 +36,7 @@ app.use(cors()); .get('/mock/users.jsonld', async (req, res) => { const limit = Number(req.query.limit); const offset = Number(req.query.offset); - const val = req.query['search-terms'] || ''; + const val = String(req.query['search-terms'] || ''); const jsonData = await fs.readFile( './examples/data/list/users-mocked.jsonld', @@ -64,13 +67,17 @@ app.use(cors()); console.log(addr); return; } - let test; + /** @type {Partial<CypressCommandLine.CypressOpenOptions>}) */ + const opt = { + testingType:'e2e', + browser: 'electron', + config: { + e2e: { baseUrl: addr }, + }, + }; + /** @type {void | CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult} */ + let test = undefined; try { - const opt = { - config: { - baseUrl: addr, - }, - }; test = process.argv.includes('--test-ui') ? await cypress.open(opt) : await cypress.run(opt); @@ -78,7 +85,7 @@ app.use(cors()); console.error(error); } finally { server.close(); - if (test.totalFailed) { + if (test && 'totalFailed' in test && test.totalFailed > 0) { process.exit(1); } } -- GitLab From cb360f84641ed4bca4f2600f9642e8647bc84f8b Mon Sep 17 00:00:00 2001 From: Anastasia Kryukova <anastasia.kryukova@protonmail.com> Date: Wed, 20 Nov 2024 17:23:10 +0100 Subject: [PATCH 28/66] minor: detach solid map and solid calendar from core --- cypress/e2e/e2e/solid-map.cy.ts | 60 ------- examples/data/calendar/event-1.jsonld | 7 - examples/data/calendar/event-2.jsonld | 7 - examples/data/calendar/events.jsonld | 16 -- examples/data/map/event-1.jsonld | 9 - examples/data/map/event-2.jsonld | 9 - examples/data/map/event-3.jsonld | 9 - examples/data/map/events.jsonld | 55 ------ examples/data/map/other-events.jsonld | 15 -- examples/data/map/source.jsonld | 22 --- examples/e2e/solid-map.html | 86 ---------- examples/filtered-map.html | 40 ----- examples/solid-calendar.html | 35 ---- examples/solid-map.html | 33 ---- index.html | 3 - package-lock.json | 87 ---------- package.json | 5 - src/components/solid-calendar.ts | 66 -------- src/components/solid-map.ts | 232 -------------------------- src/index.ts | 2 - src/style/default-theme.css | 24 --- 21 files changed, 822 deletions(-) delete mode 100644 cypress/e2e/e2e/solid-map.cy.ts delete mode 100644 examples/data/calendar/event-1.jsonld delete mode 100644 examples/data/calendar/event-2.jsonld delete mode 100644 examples/data/calendar/events.jsonld delete mode 100644 examples/data/map/event-1.jsonld delete mode 100644 examples/data/map/event-2.jsonld delete mode 100644 examples/data/map/event-3.jsonld delete mode 100644 examples/data/map/events.jsonld delete mode 100644 examples/data/map/other-events.jsonld delete mode 100644 examples/data/map/source.jsonld delete mode 100644 examples/e2e/solid-map.html delete mode 100644 examples/filtered-map.html delete mode 100644 examples/solid-calendar.html delete mode 100644 examples/solid-map.html delete mode 100644 src/components/solid-calendar.ts delete mode 100644 src/components/solid-map.ts delete mode 100644 src/style/default-theme.css diff --git a/cypress/e2e/e2e/solid-map.cy.ts b/cypress/e2e/e2e/solid-map.cy.ts deleted file mode 100644 index 71468bf0..00000000 --- a/cypress/e2e/e2e/solid-map.cy.ts +++ /dev/null @@ -1,60 +0,0 @@ -describe('solid-map', function() { - this.beforeEach('visit', () => { - cy.visit('/examples/e2e/solid-map.html') - }) - - it('display markers', () => { - cy.get('#map-1 .leaflet-marker-pane').children().should('have.length', 6) - }) - - it('display content in popup markers', () => { - cy.get('#map-2 .leaflet-marker-pane').children().first().click({force: true}) - cy.get('#map-2 .leaflet-popup-pane').children().should('have.length', 1) - cy.get('#map-2 .leaflet-popup-content solid-display') - .should('have.length', 1) - .and('have.attr', 'data-src', '/examples/data/map/event-1.jsonld') - cy.get('#map-2 .leaflet-popup-content solid-display > div > solid-set-default') - .should('have.length', 1) - .and('have.attr', 'name', 'infos') - cy.get('#map-2 .leaflet-popup-content solid-display > div > solid-set-default[name=infos] > solid-display-value').should('have.length', 2) - cy.get('#map-2 .leaflet-popup-content solid-display > div > solid-set-default[name=infos] > solid-display-value[name=name]').contains('Test 1') - cy.get('#map-2 .leaflet-popup-content solid-display > div > solid-set-default[name=infos] > solid-display-value[name=category]').contains('showcase event') - }) - - it('groups markers', () => { - cy.get('#map-3 .leaflet-marker-pane .group-meetup').should('have.length', 4) - cy.get('#map-3 .leaflet-marker-pane .group-showcaseevent').should('have.length', 2) - }) - - it('applies attributes', () => { - cy.get('#map-4 .leaflet-marker-pane').children().first().click({force: true}) - cy.get('#map-4 .leaflet-popup-content solid-display-div[name=name]') - .should('have.length', 1) - .should('have.class', 'test-class-name') - cy.get('#map-4 .leaflet-popup-content solid-display-div[name=name] button') - .should('have.length', 1) - .contains('Modifier') - .click() - cy.get('#map-4 .leaflet-popup-content solid-display-div[name=name] > div') - .should('have.attr', "contenteditable") - }) - - it('filters markers', () => { - cy.get('#filter input[name=category]').type('showcase') - cy.get('#map-5 .leaflet-marker-pane').children().should('have.length', 2) - cy.get('#map-5 span#counter').contains('2 results') - cy.get('#filter input[name=category]').clear().type('mee') - cy.get('#map-5 .leaflet-marker-pane').children().should('have.length', 4) - cy.get('#map-5 span#counter').contains('4 results') - }) - - it('markers clusters', () => { - cy.get('#map-6 .leaflet-marker-pane').children().should('have.length', 3) - cy.get('#map-6 .leaflet-marker-pane').children().eq(2) - .find('span').should('contain', '4') - }) - - it('display federated markers', () => { - cy.get('#map-federated .leaflet-marker-pane').children().should('have.length', 7) - }) -}) diff --git a/examples/data/calendar/event-1.jsonld b/examples/data/calendar/event-1.jsonld deleted file mode 100644 index d7d6820f..00000000 --- a/examples/data/calendar/event-1.jsonld +++ /dev/null @@ -1,7 +0,0 @@ -{ - "@id": "/examples/data/calendar/event-1.jsonld", - "name": "Test", - "deadline": "2019-09-09T19:55:44Z", - "permissions": [], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} diff --git a/examples/data/calendar/event-2.jsonld b/examples/data/calendar/event-2.jsonld deleted file mode 100644 index e27b3498..00000000 --- a/examples/data/calendar/event-2.jsonld +++ /dev/null @@ -1,7 +0,0 @@ -{ - "@id": "/examples/data/calendar/event-2.jsonld", - "name": "Test demain", - "deadline": "2019-09-10T19:55:56Z", - "permissions": [], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} diff --git a/examples/data/calendar/events.jsonld b/examples/data/calendar/events.jsonld deleted file mode 100644 index d539f88e..00000000 --- a/examples/data/calendar/events.jsonld +++ /dev/null @@ -1,16 +0,0 @@ -{ - "@type": "ldp:Container", - "ldp:contains": [{ - "@id": "/examples/data/calendar/event-1.jsonld", - "name": "Test", - "deadline": "2019-09-09T19:55:44Z", - "permissions": [] - }, { - "@id": "/examples/data/calendar/event-2.jsonld", - "name": "Test demain", - "deadline": "2019-09-10T19:55:56Z", - "permissions": [] - }], - "@id": "/examples/data/calendar/events.jsonld", - "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} diff --git a/examples/data/map/event-1.jsonld b/examples/data/map/event-1.jsonld deleted file mode 100644 index b745c872..00000000 --- a/examples/data/map/event-1.jsonld +++ /dev/null @@ -1,9 +0,0 @@ -{ - "@id": "/examples/data/map/event-1.jsonld", - "name": "Test", - "category": "showcase event", - "lat": "21.028511", - "lng": "105.804817", - "permissions": [], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} diff --git a/examples/data/map/event-2.jsonld b/examples/data/map/event-2.jsonld deleted file mode 100644 index ddf97bf9..00000000 --- a/examples/data/map/event-2.jsonld +++ /dev/null @@ -1,9 +0,0 @@ -{ - "@id": "/examples/data/map/event-2.jsonld", - "name": "Test", - "category": "meetup", - "lat": "48.864716", - "lng": "2.349014", - "permissions": [], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} diff --git a/examples/data/map/event-3.jsonld b/examples/data/map/event-3.jsonld deleted file mode 100644 index d081d5f1..00000000 --- a/examples/data/map/event-3.jsonld +++ /dev/null @@ -1,9 +0,0 @@ -{ - "@id": "/examples/data/map/event-3.jsonld", - "name": "Test 3", - "category": "showcase event", - "lat": "41.8902102", - "lng": "12.4922309", - "permissions": [], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} diff --git a/examples/data/map/events.jsonld b/examples/data/map/events.jsonld deleted file mode 100644 index b674eef6..00000000 --- a/examples/data/map/events.jsonld +++ /dev/null @@ -1,55 +0,0 @@ -{ - "@type": "ldp:Container", - "ldp:contains": [ - { - "name": "Test 1, Vietnam, Asia", - "category": "showcase event", - "lat": "21.028511", - "lng": "105.804817", - "permissions": [], - "@id": "/examples/data/map/event-1.jsonld" - }, - { - "name": "Test 2, France, Europe", - "category": "meetup", - "lat": "48.864716", - "lng": "2.349014", - "permissions": [], - "@id": "/examples/data/map/event-2.jsonld" - }, - { - "name": "Test 3, Italy, Europe", - "category": "showcase event", - "lat": "41.8902102", - "lng": "12.4922309", - "permissions": [], - "@id": "/examples/data/map/event-3.jsonld" - }, - { - "name": "Test 4, France, Europe", - "category": "meetup", - "lat": "48.63976", - "lng": "-2.42516", - "permissions": [], - "@id": "/examples/data/map/event-4.jsonld" - }, - { - "name": "Test 5, France, Europe", - "category": "meetup", - "lat": "48.64636", - "lng": "-2.41981", - "permissions": [], - "@id": "/examples/data/map/event-5.jsonld" - }, - { - "name": "Test 6, France, Europe", - "category": "meetup", - "lat": "48.63683", - "lng": "-2.47765", - "permissions": [], - "@id": "/examples/data/map/event-6.jsonld" - } - ], - "@id": "/examples/data/map/events.jsonld", - "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} diff --git a/examples/data/map/other-events.jsonld b/examples/data/map/other-events.jsonld deleted file mode 100644 index 16f5e8c9..00000000 --- a/examples/data/map/other-events.jsonld +++ /dev/null @@ -1,15 +0,0 @@ -{ - "@type": "ldp:Container", - "ldp:contains": [ - { - "name": "Test 7, New York", - "category": "other event", - "lat": "40.741895", - "lng": "-73.989308", - "permissions": [], - "@id": "/examples/data/map/event-7.jsonld" - } - ], - "@id": "/examples/data/map/other-events.jsonld", - "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} diff --git a/examples/data/map/source.jsonld b/examples/data/map/source.jsonld deleted file mode 100644 index 97a5affe..00000000 --- a/examples/data/map/source.jsonld +++ /dev/null @@ -1,22 +0,0 @@ -{ - "@id": "/examples/data/map/source.jsonld", - "@type": "ldp:Container", - "ldp:contains": [ - { - "federation": "events", - "@id": "/examples/data/map/events.jsonld", - "@type": "sib:federatedContainer", - "permissions": [ - "view" - ] - }, - { - "@id": "/examples/data/map/other-events.jsonld", - "@type": "sib:federatedContainer" - } - ], - "permissions": [ - "view" - ], - "@context": "https://cdn.startinblox.com/owl/context.jsonld" -} diff --git a/examples/e2e/solid-map.html b/examples/e2e/solid-map.html deleted file mode 100644 index 76401273..00000000 --- a/examples/e2e/solid-map.html +++ /dev/null @@ -1,86 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> - <head> - <meta charset="UTF-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <meta http-equiv="X-UA-Compatible" content="ie=edge" /> - <title>SIB test: solid-map</title> - <script type="module" src="../../dist/index.js"></script> - <script> - document.addEventListener("DOMContentLoaded", event => { - document.querySelector("solid-map").addEventListener("resourceSelect", event => console.log(event.detail.resource)); - }); - </script> - - <link rel="stylesheet" href="../styles.css" /> - </head> - - <body> - <h2>solid-map</h2> - - <solid-map - id="map-1" - data-src="/examples/data/map/events.jsonld" - style="display: block; width: 800px; height: 600px;" - ></solid-map> - <br> - <solid-map - id="map-2" - data-src="/examples/data/map/events.jsonld" - fields="infos(name, category)" - style="display: block; width: 800px; height: 600px;" - ></solid-map> - <br> - <solid-map - id="map-3" - data-src="/examples/data/map/events.jsonld" - group-by="category" - style="display: block; width: 800px; height: 600px;" - ></solid-map> - <br> - <solid-map - id="map-4" - data-src="/examples/data/map/events.jsonld" - fields="infos(name, category)" - group-by="category" - class-name="test-class-name" - widget-name="solid-display-div" - editable-name - style="display: block; width: 800px; height: 600px;" - ></solid-map> - <br> - <solid-form-search - id="filter" - fields="category" - ></solid-form-search> - <br> - <solid-map - id="map-5" - data-src="/examples/data/map/events.jsonld" - fields="name, category" - filtered-by="filter" - counter-template="<span id='counter'>${counter} results<span>" - style="display: block; width: 800px; height: 600px;" - ></solid-map> -<br> - <solid-map - id="map-6" - data-src="/examples/data/map/events.jsonld" - fields="name, category" - style="display: block; width: 800px; height: 600px;" - clustering - ></solid-map> - <br> - <solid-map - id="map-federated" - data-src="/examples/data/map/source.jsonld" - style="display: block; width: 800px; height: 600px;" - ></solid-map> - - <style> - .group-meetup { - border-color: coral; - } - </style> - </body> -</html> diff --git a/examples/filtered-map.html b/examples/filtered-map.html deleted file mode 100644 index ed9bcb1e..00000000 --- a/examples/filtered-map.html +++ /dev/null @@ -1,40 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> - <head> - <meta charset="UTF-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <meta http-equiv="X-UA-Compatible" content="ie=edge" /> - <title>SIB test: filtered solid-map</title> - <script type="module" src="../dist/index.js"></script> - <script> - document.addEventListener("DOMContentLoaded", event => { - document.querySelector("solid-map").addEventListener("resourceSelect", event => console.log(event.detail.resource)); - }); - </script> - - <link rel="stylesheet" href="styles.css" /> - </head> - - <body> - <h2>Filtered Solid Map</h2> - <solid-form-search - id="filter" - fields="name" - label-name='Filter places (try "Europe")' - submit-button="update map" - ></solid-form-search> - <solid-map - data-src="/examples/data/map/events.jsonld" - fields="infos(name, category)" - group-by="category" - filtered-by="filter" - style="display: block; width: 800px; height: 600px;" - ></solid-map> - - <style> - .group-meetup { - border-color: coral; - } - </style> - </body> -</html> diff --git a/examples/solid-calendar.html b/examples/solid-calendar.html deleted file mode 100644 index 00aa4c3b..00000000 --- a/examples/solid-calendar.html +++ /dev/null @@ -1,35 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> - <head> - <meta charset="UTF-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <meta http-equiv="X-UA-Compatible" content="ie=edge" /> - <title>SIB test: solid-calendar</title> - <script type="module" src="../dist/components/solid-calendar.js"></script> - <script> - document.addEventListener('DOMContentLoaded', event => { - document - .querySelector('solid-calendar') - .addEventListener('resourceSelect', event => - console.log(event.detail.resource), - ); - }); - </script> - <style> - solid-calendar { - display: block; - width: 800px; - height: 600px; - border: 1px solid red; - position: relative; - } - .tui-view-7{ - height: 100% !important; - } - </style> - </head> - <body> - <h2>solid-calendar</h2> - <solid-calendar data-src="/examples/data/calendar/events.jsonld"></solid-calendar> - </body> -</html> diff --git a/examples/solid-map.html b/examples/solid-map.html deleted file mode 100644 index c746cf37..00000000 --- a/examples/solid-map.html +++ /dev/null @@ -1,33 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> - <head> - <meta charset="UTF-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <meta http-equiv="X-UA-Compatible" content="ie=edge" /> - <title>SIB test: solid-map</title> - <script type="module" src="../dist/index.js"></script> - <script> - document.addEventListener("DOMContentLoaded", event => { - document.querySelector("solid-map").addEventListener("resourceSelect", event => console.log(event.detail.resource)); - }); - </script> - - <link rel="stylesheet" href="styles.css" /> - </head> - - <body> - <h2>Solid Map</h2> - <solid-map - data-src="/examples/data/map/events.jsonld" - fields="infos(name, category)" - group-by="category" - style="display: block; width: 800px; height: 600px;" - ></solid-map> - - <style> - .group-meetup { - border-color: coral; - } - </style> - </body> -</html> diff --git a/index.html b/index.html index 96fb5be9..ce13ee5c 100644 --- a/index.html +++ b/index.html @@ -26,8 +26,6 @@ <li><a href="./examples/solid-display.html">solid-display</a></li> <li><a href="./examples/solid-display-server-search.html">solid-display, with server search</a></li> <li><a href="./examples/solid-form.html">solid-form</a></li> - <li><a href="./examples/solid-map.html">solid-map</a></li> - <li><a href="./examples/solid-calendar.html">solid-calendar</a></li> <li><a href="./examples/solid-delete.html">solid-delete</a></li> <li><a href="./examples/solid-ac-checker.html">solid-ac-checker</a></li> <li><a href="./examples/solid-widget.html">solid-widget</a></li> @@ -54,7 +52,6 @@ <ul> <li><a href="./examples/search.html">search</a></li> <li><a href="./examples/filtered.html">filtered-by</a></li> - <li><a href="./examples/filtered-map.html">filtered-by + solid-map</a></li> <li><a href="./examples/pagination.html">pagination</a></li> <li><a href="./examples/counter.html">counter</a></li> <li><a href="./examples/order-by.html">order-by</a></li> diff --git a/package-lock.json b/package-lock.json index 2888b4bd..3597e9f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,8 +16,6 @@ "devDependencies": { "@rckeller/cypress-unfetch": "^1.0.1", "@types/autolinker": "^2.0.0", - "@types/leaflet": "^1.9.12", - "@types/leaflet.markercluster": "^1.5.4", "@types/markdown-it": "^14.1.2", "@types/node": "^22.7.1", "@types/pubsub-js": "^1.8.6", @@ -31,8 +29,6 @@ "fuse.js": "^7.0.0", "jsonld": "^8.3.2", "jsonld-context-parser": "^1.3.4", - "leaflet": "1.9.4", - "leaflet.markercluster": "1.5.3", "markdown-it": "^14.1.0", "markdown-it-link-attributes": "4.0.1", "pubsub-js": "^1.9.4", @@ -40,7 +36,6 @@ "quill-delta-to-markdown": "^0.6.0", "semver": "7.6.3", "slim-select": "^2.9.2", - "tui-calendar": "^1.15.3", "typescript": "^5.6.2", "vite": "^5.4.8" } @@ -865,32 +860,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/geojson": { - "version": "7946.0.10", - "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.10.tgz", - "integrity": "sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA==", - "dev": true - }, - "node_modules/@types/leaflet": { - "version": "1.9.12", - "resolved": "https://registry.npmjs.org/@types/leaflet/-/leaflet-1.9.12.tgz", - "integrity": "sha512-BK7XS+NyRI291HIo0HCfE18Lp8oA30H1gpi1tf0mF3TgiCEzanQjOqNZ4x126SXzzi2oNSZhZ5axJp1k0iM6jg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/geojson": "*" - } - }, - "node_modules/@types/leaflet.markercluster": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/@types/leaflet.markercluster/-/leaflet.markercluster-1.5.4.tgz", - "integrity": "sha512-tfMP8J62+wfsVLDLGh5Zh1JZxijCaBmVsMAX78MkLPwvPitmZZtSin5aWOVRhZrCS+pEOZwNzexbfWXlY+7yjg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/leaflet": "*" - } - }, "node_modules/@types/linkify-it": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz", @@ -1857,13 +1826,6 @@ "integrity": "sha512-ZbVDJI9uvxPAKze6z146rmfUZjBqNEwcnFTVamQzXH+svluiV7swmVIGr7miwADgfgt1G2JQIytypM9fbyhX4w==", "dev": true }, - "node_modules/dompurify": { - "version": "2.5.6", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.5.6.tgz", - "integrity": "sha512-zUTaUBO8pY4+iJMPE1B9XlO2tXVYIcEA4SNGtvDELzTSCQO7RzH+j7S180BmhmJId78lqGU2z19vgVx2Sxs/PQ==", - "dev": true, - "license": "(MPL-2.0 OR Apache-2.0)" - }, "node_modules/ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -2932,22 +2894,6 @@ "node": "> 0.8" } }, - "node_modules/leaflet": { - "version": "1.9.4", - "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.9.4.tgz", - "integrity": "sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==", - "dev": true, - "license": "BSD-2-Clause" - }, - "node_modules/leaflet.markercluster": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/leaflet.markercluster/-/leaflet.markercluster-1.5.3.tgz", - "integrity": "sha512-vPTw/Bndq7eQHjLBVlWpnGeLa3t+3zGiuM7fJwCkiMFq+nmRuG3RI3f7f4N4TDX7T4NpbAXpR2+NTRSEGfCSeA==", - "dev": true, - "peerDependencies": { - "leaflet": "^1.3.1" - } - }, "node_modules/linkify-it": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", @@ -4389,39 +4335,6 @@ "integrity": "sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig==", "dev": true }, - "node_modules/tui-calendar": { - "version": "1.15.3", - "resolved": "https://registry.npmjs.org/tui-calendar/-/tui-calendar-1.15.3.tgz", - "integrity": "sha512-S+QxtSPunLUNIX/eHoHcBB9XlPVT15Wh6ItR62n5K/Gq3WeSQdyhdbsuZJYV9z75bgJbFzp6x32v2yEPm6iWrg==", - "dev": true, - "dependencies": { - "dompurify": "^2.3.1", - "tui-code-snippet": "^1.5.0", - "tui-date-picker": "^4.3.0", - "tui-time-picker": "^2.1.4" - } - }, - "node_modules/tui-code-snippet": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/tui-code-snippet/-/tui-code-snippet-1.5.2.tgz", - "integrity": "sha512-6UqTlQaaC1KLcmC0HAoq5dtl1G4Fib+R+NC7pmaV7kiIlZ7JqKhUmnOoGRcreAyzd81UTK/vCvhrw9QJskpCFQ==", - "dev": true - }, - "node_modules/tui-date-picker": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/tui-date-picker/-/tui-date-picker-4.3.3.tgz", - "integrity": "sha512-/2YoLnj5c1e+Ag1ZZYOgzEs2o0v7Ol7c5UAnBj438zGlkwkMxyH0HwP2pVqqIYX05WE7K0+6nTWVMybS8otBgw==", - "dev": true, - "dependencies": { - "tui-time-picker": "^2.1.6" - } - }, - "node_modules/tui-time-picker": { - "version": "2.1.6", - "resolved": "https://registry.npmjs.org/tui-time-picker/-/tui-time-picker-2.1.6.tgz", - "integrity": "sha512-4Jmo3wjGS+Ii4/qQgt5DaFEohHpB3U6BzWeTODVVFHD9sx3NOsbomY9K0xMobSLODi+tQEH7wfOtNU0IJmcQ6Q==", - "dev": true - }, "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", diff --git a/package.json b/package.json index 70bb0830..a103d2e5 100644 --- a/package.json +++ b/package.json @@ -67,8 +67,6 @@ "devDependencies": { "@rckeller/cypress-unfetch": "^1.0.1", "@types/autolinker": "^2.0.0", - "@types/leaflet": "^1.9.12", - "@types/leaflet.markercluster": "^1.5.4", "@types/markdown-it": "^14.1.2", "@types/node": "^22.7.1", "@types/pubsub-js": "^1.8.6", @@ -82,8 +80,6 @@ "fuse.js": "^7.0.0", "jsonld": "^8.3.2", "jsonld-context-parser": "^1.3.4", - "leaflet": "1.9.4", - "leaflet.markercluster": "1.5.3", "markdown-it": "^14.1.0", "markdown-it-link-attributes": "4.0.1", "pubsub-js": "^1.9.4", @@ -91,7 +87,6 @@ "quill-delta-to-markdown": "^0.6.0", "semver": "7.6.3", "slim-select": "^2.9.2", - "tui-calendar": "^1.15.3", "typescript": "^5.6.2", "vite": "^5.4.8" }, diff --git a/src/components/solid-calendar.ts b/src/components/solid-calendar.ts deleted file mode 100644 index 90fac451..00000000 --- a/src/components/solid-calendar.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { Sib } from '../libs/Sib'; -import { ListMixin } from '../mixins/listMixin'; -import { StoreMixin } from '../mixins/storeMixin'; -import { NextMixin } from '../mixins/nextMixin'; -import { store } from '../libs/store/store'; -import { importInlineCSS, uniqID } from '../libs/helpers'; - -import Calendar from 'tui-calendar'; -import { html, render } from 'lit'; - -export const SolidCalendar = { - name: 'solid-calendar', - use: [ - ListMixin, - StoreMixin, - NextMixin - ], - initialState: { - subscriptions: null - }, - created(): void { - importInlineCSS('tui-calendar', () => import('tui-calendar/dist/tui-calendar.css?inline')) - - const id = uniqID(); - const template = html`<div id=${id} style="width:100%;height:100%;"></div>`; - render(template, this.element); - this.calendar = new Calendar(this.element.querySelector(`#${id}`), { defaultView: 'month' }); - this.calendar.on('clickSchedule', this.dispatchSelect.bind(this)); - this.subscriptions = new Map(); - }, - get extra_context(): object { - return { date: "http://www.w3.org/2001/XMLSchema#dateTime" } - }, - dispatchSelect(event: Event): void { - const resource = { '@id': event['schedule'].id }; - this.element.dispatchEvent( - new CustomEvent('resourceSelect', { detail: { resource: resource } }), - ); - this.goToNext(resource); - }, - async appendChildElt(resourceId: string) { - const resource = await store.getData(resourceId, this.context); - if(!resource) return; - if (!this.subscriptions.get(resourceId)) { - this.subscriptions.set(resourceId, PubSub.subscribe(resourceId, () => this.updateDOM())) - } // TODO : mixin gestion des enfants - const date = await resource['date']; - const name = await resource['name']; - - if (name && date) { - this.calendar.createSchedules([ - { - id: resource['@id'], - title: name.toString(), - category: 'time', - start: date.toString(), - }, - ]); - } - }, - empty(): void { - this.calendar.clear(); - } -}; - -Sib.register(SolidCalendar); \ No newline at end of file diff --git a/src/components/solid-map.ts b/src/components/solid-map.ts deleted file mode 100644 index 27eb5692..00000000 --- a/src/components/solid-map.ts +++ /dev/null @@ -1,232 +0,0 @@ -import { Sib } from '../libs/Sib'; -import { ListMixin } from '../mixins/listMixin'; -import { StoreMixin } from '../mixins/storeMixin'; -import { WidgetMixin } from '../mixins/widgetMixin'; -import { CounterMixin } from '../mixins/counterMixin'; -import { FilterMixin } from '../mixins/filterMixin'; -import { FederationMixin } from '../mixins/federationMixin'; -import { GrouperMixin } from '../mixins/grouperMixin'; -import { NextMixin } from '../mixins/nextMixin'; -import { store } from '../libs/store/store'; -import { importInlineCSS, uniqID } from '../libs/helpers'; -import { spread } from '../libs/lit-helpers'; - -//@ts-ignore -import L, { MarkerOptions } from 'https://cdn.skypack.dev/leaflet'; // TODO : revert to "leaflet" when apps up to date -import 'https://cdn.skypack.dev/leaflet.markercluster'; // TODO : revert to "leaflet.markercluster" when apps up to date - -import { html, render } from 'lit'; -import { ifDefined } from 'lit/directives/if-defined.js'; -import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; -import { trackRenderAsync } from '../logger'; - -export const SolidMap = { - name: 'solid-map', - use: [ - WidgetMixin, - ListMixin, - StoreMixin, - GrouperMixin, - CounterMixin, - FilterMixin, - FederationMixin, - NextMixin, - ], - attributes: { - clustering: { - type: Boolean, - default: null - } - }, - initialState: { - markers: { - default: null - }, - subscriptions: null, - resetPlanned: false, - hasBeenResetOnce: false - }, - created(): void { - importInlineCSS('leaflet', () => import('leaflet/dist/leaflet.css?inline')) - importInlineCSS('default-theme', () => import('../style/default-theme.css?inline')) - importInlineCSS('marker-cluster', () => import('leaflet.markercluster/dist/MarkerCluster.css?inline')) - importInlineCSS('marker-cluster-default', () => import('leaflet.markercluster/dist/MarkerCluster.Default.css?inline')) - - // reset when it becomes visible to prevent bug https://git.startinblox.com/framework/sib-core/issues/661 - document.body.addEventListener('navigate', () => - setTimeout(() => this.isVisible && !this.hasBeenResetOnce && this.reset()) - ); - this.markers = []; - this.subscriptions = new Map(); - }, - get isVisible() { - return this.element.offsetParent !== null - }, - attached(): void { - const id = uniqID(); - const template = html` - <div id=${id} style="width:100%;height:100%;"></div> - `; - render(template, this.element); - - const div = this.element.querySelector(`#${id}`); - this.map = L.map(div); - - L.tileLayer( - 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png' - ).addTo(this.map); - - if (this.clustering !== null) { - this.markersCluster = L.markerClusterGroup(); - this.map.addLayer(this.markersCluster); - } - }, - reset() { - if (this.isVisible) { // reset only if visible - this.map.invalidateSize(); - - if (this.markers.length) { - this.map.fitBounds(L.featureGroup(this.markers).getBounds()); // Center map on markers if some available - } else { - this.map.fitWorld(); // ... or on the world if not - } - this.hasBeenResetOnce = true; - } - }, - /** - * Execute a reset only if none is planned already - */ - planReset() { - if (!this.resetPlanned) { - this.resetPlanned = true; - setTimeout(() => { - this.reset(); - this.resetPlanned = false; - }) - } - }, - dispatchSelect(event: CustomEvent): void { - const target = event.target as Element; - const resource = target['options'].resource; - this.element.dispatchEvent( - new CustomEvent('resourceSelect', { detail: { resource: resource } }) - ); - this.goToNext(resource); - }, - - /** - * Override listMixin method: initialize a marker on the map - * @param resourceId: id of the resource to display - * @param groupClass: class of the group of markers - */ - async appendChildElt(resourceId: string, groupClass: string) { - const resource = await store.getData(resourceId, this.context); - if (!this.subscriptions.get(resourceId)) { - this.subscriptions.set(resourceId, PubSub.subscribe(resourceId, () => this.updateDOM())) - } - if (!resource) return; - const lat = await resource['lat']; - const lng = await resource['lng']; - - if (lat && lng) { - const icon = L.divIcon({ // create the icon, doc here: https://leafletjs.com/reference-1.6.0.html#icon - className: 'sib-custom-marker ' + groupClass, // default class used for styling - iconSize: [8, 8], - iconAnchor: [12, 34], - popupAnchor: [0,-34] - }); - - // create a marker, doc here: https://leafletjs.com/reference-1.6.0.html#marker - const marker = L.marker( - [lat.toString(), lng.toString()], - {resource, icon} as MarkerOptions - ); - if(this.clustering === null) marker.addTo(this.map); - else this.markersCluster.addLayer(marker); - marker.on('click', this.dispatchSelect.bind(this)); - - if (this.fields !== null) { // show popups only if fields attribute - marker.bindPopup(() => this.getPopupContent(resourceId), { minWidth: 150 }) // re-generate popup solid-display - } - - this.markers.push(marker); - } - }, - /** - * Generate the solid-display of the popup - * @param resourceId: id of the popup clicked - */ - getPopupContent(resourceId: string) { - const attributes:{[key:string]: string} = {}; - - for (let attr of this.element.attributes) { - //copy widget and value attributes - if ( - attr.name.startsWith('value-') || - attr.name.startsWith('label-') || - attr.name.startsWith('widget-') || - attr.name.startsWith('class-') || - attr.name.startsWith('multiple-') || - attr.name.startsWith('editable-') || - attr.name.startsWith('action-') || - attr.name.startsWith('default-') || - attr.name == 'extra-context' - ) - attributes[attr.name] = attr.value; - if (attr.name.startsWith('child-')) - attributes[attr.name.replace(/^child-/, '')] = attr.value; - } - - const div = document.createElement('div'); - const template = html` - <solid-display - fields="${ifDefined(this.fields)}" - data-src="${resourceId}" - ...=${spread(attributes)} - ></solid-display> - `; - render(template, div); - return div.querySelector('solid-display'); - }, - /** - * Override widgetMixin method: empty the map - */ - empty(): void { - if (!this.map) return; - if (this.markersCluster) this.map.removeLayer(this.markersCluster); - for (let marker of this.markers) this.map.removeLayer(marker); - if(this.clustering !== null) { - this.markersCluster = L.markerClusterGroup(); - this.map.addLayer(this.markersCluster); - } - this.markers = []; - }, - /** - * Override groupMixin method - * @param groupName: value of the group - */ - renderGroup(groupName: string) { - const sanitizedGroupName = encodeURIComponent(groupName.toLowerCase()).replace(/%[0-9A-F]{2}/gi, ''); - const div = document.createElement('div'); // used to pass group info to renderDOM - div.dataset.groupClass = 'group-' + sanitizedGroupName; - return div; - }, - /** - * Override listMixin method: display all the resources - * @param resources - * @param listPostProcessors - * @param div - * @param context - */ - renderDOM: trackRenderAsync( - async function(resources: object[], listPostProcessors: PostProcessorRegistry, div: HTMLElement, context: string) { - const groupClass = div.dataset.groupClass || ''; // get the group class from the useless div element - await Promise.all(resources.map(resource => this.appendChildElt(resource['@id'], groupClass))) - this.planReset(); - - const nextProcessor = listPostProcessors.shift(); - if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context); - }, "SolidMap:renderDOM" ) -}; - -Sib.register(SolidMap); \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 680d5358..f059cfe4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,7 +8,6 @@ import { SolidAcChecker } from './components/solid-ac-checker'; import { SolidDelete } from './components/solid-delete'; import { SolidLang } from './components/solid-lang'; import { SolidTable } from './components/solid-table'; -import { SolidMap } from './components/solid-map'; import { SolidMembership } from './components/solid-membership'; import { SolidMemberDelete } from './components/solid-member-delete'; import { SolidMemberAdd } from './components/solid-member-add'; @@ -61,7 +60,6 @@ export { SolidDelete, SolidLang, SolidTable, - SolidMap, SolidMembership, SolidMemberDelete, SolidMemberAdd, diff --git a/src/style/default-theme.css b/src/style/default-theme.css deleted file mode 100644 index da97c874..00000000 --- a/src/style/default-theme.css +++ /dev/null @@ -1,24 +0,0 @@ -/*==== SOLID-MAP ====*/ -/* map custom marker */ -.sib-custom-marker { - position: absolute; - top: 40%; - left: 50%; - margin-left: 115px; - border-radius: 50%; - border: 8px solid #1c78c9; - width: 8px; - height: 8px; -} -.sib-custom-marker::after { - position: absolute; - content: ''; - width: 0px; - height: 0px; - bottom: -30px; - left: -6px; - border: 10px solid transparent; - border-top-width: 17px; - border-top-style: solid; - border-top-color: inherit; -} \ No newline at end of file -- GitLab From b41f621231e0cb8b6110898d884f5f5d2fbdb596 Mon Sep 17 00:00:00 2001 From: Benoit Alessandroni <benoit@startinblox.com> Date: Wed, 20 Nov 2024 17:39:33 +0100 Subject: [PATCH 29/66] fix: linter issues --- cypress/e2e/e2e/solid-form-richtext.cy.ts | 14 ++++++-------- server.js | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/cypress/e2e/e2e/solid-form-richtext.cy.ts b/cypress/e2e/e2e/solid-form-richtext.cy.ts index 9d1feb6c..8ede29d4 100644 --- a/cypress/e2e/e2e/solid-form-richtext.cy.ts +++ b/cypress/e2e/e2e/solid-form-richtext.cy.ts @@ -15,10 +15,9 @@ describe('solid-form-richtext test', function () { }); it('Submitting form with empty rich text input should display an error mesage', () => { - cy.get('#form-1 div[data-richtext] [contenteditable]').should( - 'have.text', - 'some description' - ).clear(); + cy.get('#form-1 div[data-richtext] [contenteditable]') + .should('have.text', 'some description') + .clear(); cy.get('#form-1 div[data-richtext] p').clear(); cy.get('#form-1 input[type="submit"]').click(); cy.get('#form-1 div[data-richtext] .required-error-message').should( @@ -29,10 +28,9 @@ describe('solid-form-richtext test', function () { it('Error message disappears when retyping in rich text input', () => { // Empty fields , error is shown - cy.get('#form-1 div[data-richtext] [contenteditable]').should( - 'have.text', - 'some description' - ).clear(); + cy.get('#form-1 div[data-richtext] [contenteditable]') + .should('have.text', 'some description') + .clear(); cy.get('#form-1 input[type="submit"]').click(); cy.get('#form-1 div[data-richtext] .required-error-message').should( 'exist', diff --git a/server.js b/server.js index 69370033..ee7d39ba 100644 --- a/server.js +++ b/server.js @@ -69,7 +69,7 @@ process.env.ELECTRON_EXTRA_LAUNCH_ARGS = '--lang=en'; } /** @type {Partial<CypressCommandLine.CypressOpenOptions>}) */ const opt = { - testingType:'e2e', + testingType: 'e2e', browser: 'electron', config: { e2e: { baseUrl: addr }, -- GitLab From 504fcea41313bb6d12f8b73b282844ebadcc3c13 Mon Sep 17 00:00:00 2001 From: Benoit Alessandroni <benoit@startinblox.com> Date: Thu, 21 Nov 2024 10:21:01 +0100 Subject: [PATCH 30/66] Update: .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 18b91617..35c4e888 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ coverage cypress/downloads .vscode .DS_Store +.npm -- GitLab From 3ea7fc53d97a0c26984ebe234839a0b05ce332af Mon Sep 17 00:00:00 2001 From: Benoit Alessandroni <benoit@startinblox.com> Date: Tue, 26 Nov 2024 15:22:48 +0100 Subject: [PATCH 31/66] fix: linter --- cypress/e2e/e2e/solid-form.cy.ts | 3 +-- src/mixins/filterMixin.ts | 4 +++- src/mixins/widgetMixin.ts | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/e2e/solid-form.cy.ts b/cypress/e2e/e2e/solid-form.cy.ts index 64d60b99..824c10fa 100644 --- a/cypress/e2e/e2e/solid-form.cy.ts +++ b/cypress/e2e/e2e/solid-form.cy.ts @@ -27,8 +27,7 @@ describe('solid-form', { testIsolation: false }, function () { cy.get('input[type=text]').should('have.length', 2); cy.get('input[name=with]').should('exist'); cy.get('input[name=field]').should('exist'); - }) - + }); }); it('edition form', () => { diff --git a/src/mixins/filterMixin.ts b/src/mixins/filterMixin.ts index f3a97895..9845903a 100644 --- a/src/mixins/filterMixin.ts +++ b/src/mixins/filterMixin.ts @@ -105,7 +105,9 @@ const FilterMixin = { this.fields, this.searchForm, ); - this.resources = resources = resources.filter((_v, index) => filteredResources[index]); + this.resources = resources = resources.filter( + (_v, index) => filteredResources[index], + ); } const nextProcessor = listPostProcessors.shift(); diff --git a/src/mixins/widgetMixin.ts b/src/mixins/widgetMixin.ts index e6baca83..f9f0a59d 100644 --- a/src/mixins/widgetMixin.ts +++ b/src/mixins/widgetMixin.ts @@ -476,7 +476,9 @@ const WidgetMixin = { } } if (!setFields.length) { - console.warn(`Set with name ${field} has not been generated due to being empty`) + console.warn( + `Set with name ${field} has not been generated due to being empty`, + ); } // Render template const widgetsTemplate = await Promise.all( -- GitLab From 7832e0a4d8df908cea1d8d6f6f5042735de3434a Mon Sep 17 00:00:00 2001 From: Benoit Alessandroni <benoit@startinblox.com> Date: Tue, 26 Nov 2024 15:29:25 +0100 Subject: [PATCH 32/66] fix: linting --- cypress/e2e/e2e/search.cy.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cypress/e2e/e2e/search.cy.ts b/cypress/e2e/e2e/search.cy.ts index 30330c5c..6b03230c 100644 --- a/cypress/e2e/e2e/search.cy.ts +++ b/cypress/e2e/e2e/search.cy.ts @@ -210,12 +210,12 @@ describe('solid-form-search widget', { testIsolation: false }, function () { }); it('solid-form-search + debounce', () => { - const input = cy.get('#filter-debounce input') - input.type('p') - cy.wait(1000) - cy.get('#debounce>div>solid-display').should('not.have.length', 4) - input.type('hp') - cy.get('#debounce>div>solid-display').should('have.length', 1) + const input = cy.get('#filter-debounce input'); + input.type('p'); + cy.wait(1000); + cy.get('#debounce>div>solid-display').should('not.have.length', 4); + input.type('hp'); + cy.get('#debounce>div>solid-display').should('have.length', 1); }); it('solid-form-search + enter should not trigger default submit', () => { -- GitLab From 71b181e148ac704818f4e0ea45912bf4194457ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 15 Nov 2024 23:29:07 +0100 Subject: [PATCH 33/66] fix `lint/correctness` errors --- biome.jsonc | 10 ++++++++-- src/mixins/attributeBinderMixin.ts | 20 +++++++------------ src/mixins/requiredMixin.ts | 4 ++-- src/mixins/serverPaginationMixin.ts | 2 +- src/mixins/widgetMixin.ts | 6 +++--- .../callbackMixins/richtextMixin.ts | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index 5b48b52f..b57a60ed 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -16,11 +16,17 @@ "enabled": false }, "linter": { - "enabled": false, + "enabled": true, "rules": { "recommended": true, + "style": { + "all": false + }, "complexity": { - "useLiteralKeys": "off" + "all": false + }, + "suspicious": { + "all": false } } }, diff --git a/src/mixins/attributeBinderMixin.ts b/src/mixins/attributeBinderMixin.ts index e410d8f9..a4bae624 100644 --- a/src/mixins/attributeBinderMixin.ts +++ b/src/mixins/attributeBinderMixin.ts @@ -25,21 +25,15 @@ const AttributeBinderMixin = { async replaceAttributesData(reset = true) { if (reset) this.resetAttributesData(); - const oldAttributes: any = Array.from(this.element.attributes) // transform NamedNodeMap in object - .reduce((obj: any, attr: any) => { - // Keep only attributes starting with `store://...` - if (!attr.value.match(/^store:\/\/(resource|container|user)/)) - return { ...obj }; + const oldAttributes: Record<string, string> = {}; + for (const attr of (this.element as Element).attributes) { + if (!attr.value.match(/^store:\/\/(resource|container|user)/)) continue; - // Save attr for reset later - if (!this.bindedAttributes[attr.name]) - this.bindedAttributes[attr.name] = attr.value; + if (!this.bindedAttributes[attr.name]) + this.bindedAttributes[attr.name] = attr.value; - return { - ...obj, - [attr.name]: attr.value, // add "key: value" - }; - }, {}); + oldAttributes[attr.name] = attr.value; + } const newAttributes = await this.transformAttributes( { ...oldAttributes }, diff --git a/src/mixins/requiredMixin.ts b/src/mixins/requiredMixin.ts index 8a86e657..ba8737d8 100644 --- a/src/mixins/requiredMixin.ts +++ b/src/mixins/requiredMixin.ts @@ -30,9 +30,9 @@ const RequiredMixin = { for (let field of requiredFields) { // Retrieve resource from store let res = await resource[field]; - if (!res || res == null) { + if (!res) { hasProps = false; - continue; + break; } } if (hasProps) displays.push(resource); diff --git a/src/mixins/serverPaginationMixin.ts b/src/mixins/serverPaginationMixin.ts index 30c0a354..c4bc511e 100644 --- a/src/mixins/serverPaginationMixin.ts +++ b/src/mixins/serverPaginationMixin.ts @@ -113,7 +113,7 @@ const ServerPaginationMixin = { renderServerPaginationNav(resourceId: string, div: HTMLElement): void { if (this.limit) { const currentOffset = this.getCurrentOffset(resourceId, this.limit); - var currentPageNumber = this.getCurrentServedPage(resourceId, 1); + const currentPageNumber = this.getCurrentServedPage(resourceId, 1); const pageCount = Math.ceil(this.pageCount / this.limit); render( diff --git a/src/mixins/widgetMixin.ts b/src/mixins/widgetMixin.ts index f9f0a59d..15905e77 100644 --- a/src/mixins/widgetMixin.ts +++ b/src/mixins/widgetMixin.ts @@ -458,12 +458,12 @@ const WidgetMixin = { // Catch widget for the set if all these fields are empty if (this.element.hasAttribute('empty-' + field)) { let hasOnlyEmpty = true; - for (let field of setFields) { - let value: string = await this.getValue(field, this.resource); + for (const field of setFields) { + const value: string = await this.getValue(field, this.resource); if (value !== '') { // if one not empty hasOnlyEmpty = false; - continue; // break loop + break; } } if (hasOnlyEmpty) { diff --git a/src/new-widgets/callbackMixins/richtextMixin.ts b/src/new-widgets/callbackMixins/richtextMixin.ts index 8070a69a..db754528 100644 --- a/src/new-widgets/callbackMixins/richtextMixin.ts +++ b/src/new-widgets/callbackMixins/richtextMixin.ts @@ -26,7 +26,7 @@ const RichtextMixin = { }, addCallback(value: string, listCallbacks: PostProcessorRegistry) { if (this.quill == null) { - var toolbarOptions = [ + const toolbarOptions = [ ['bold', 'italic'], ['blockquote'], [{ header: [1, 2, 3, 4, 5, 6, false] }], -- GitLab From 3bb66b6176ab96ee4e25b22c8a7ff06721ad5691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Sat, 16 Nov 2024 00:05:27 +0100 Subject: [PATCH 34/66] fix `lint/suspicious` errors (partial) --- biome.jsonc | 4 +++- cypress/e2e/e2e/solid-lang.cy.ts | 4 +++- src/components/solid-form.ts | 4 ++-- src/libs/ComponentFactory.ts | 4 ++-- src/libs/helpers.ts | 10 +++++++--- src/libs/lit-helpers.ts | 2 +- src/libs/polyfills.ts | 2 +- src/mixins/sorterMixin.ts | 4 ++-- src/mixins/widgetMixin.ts | 4 ++-- src/new-widgets/templateAdditionMixins/addableMixin.ts | 2 +- src/new-widgets/templatesDependencies/rangeMixin.ts | 6 ++---- src/new-widgets/valueTransformationMixins/dateMixin.ts | 2 +- src/widgets/baseWidget.ts | 7 +++---- tsconfig.json | 2 +- 14 files changed, 31 insertions(+), 26 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index b57a60ed..2d889b56 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -26,7 +26,9 @@ "all": false }, "suspicious": { - "all": false + "noExplicitAny": "off", + "noDoubleEquals": "off", + "noAsyncPromiseExecutor": "off" } } }, diff --git a/cypress/e2e/e2e/solid-lang.cy.ts b/cypress/e2e/e2e/solid-lang.cy.ts index 89fc3cb8..b35bf7cc 100644 --- a/cypress/e2e/e2e/solid-lang.cy.ts +++ b/cypress/e2e/e2e/solid-lang.cy.ts @@ -5,7 +5,9 @@ describe('solid-lang', function () { it('test solid-lang', () => { // mark in window object to show reload - cy.window().then((w: any) => (w.beforeReload = true)); + cy.window().then((w: any) => { + w.beforeReload = true; + }); // initilization of a property cy.window().should('have.prop', 'beforeReload', true); diff --git a/src/components/solid-form.ts b/src/components/solid-form.ts index e63e83c9..0b8ad40b 100644 --- a/src/components/solid-form.ts +++ b/src/components/solid-form.ts @@ -142,12 +142,12 @@ export const SolidForm = { }), ); }, - async save(): Promise<object> { + async save() { this.toggleLoaderHidden(false); this.hideError(); const resource = await this.getFormValue(); resource['@context'] = this.context; - let saved; + let saved: string | null | undefined = undefined; try { if (this.partial == null) { saved = resource['@id'] diff --git a/src/libs/ComponentFactory.ts b/src/libs/ComponentFactory.ts index b8cbd4da..26763334 100644 --- a/src/libs/ComponentFactory.ts +++ b/src/libs/ComponentFactory.ts @@ -75,8 +75,8 @@ export class ComponentFactory { attributesList.forEach(key => { const { default: def, type, required, callback } = attributes[key]; - let fromType; - let toType; + let fromType: (value: string) => unknown; + let toType: (value: unknown) => unknown; switch (type) { case String: diff --git a/src/libs/helpers.ts b/src/libs/helpers.ts index f806d3a1..a924d8a4 100644 --- a/src/libs/helpers.ts +++ b/src/libs/helpers.ts @@ -231,11 +231,11 @@ function generalComparator(a, b, order = 'asc') { if (typeof a === 'boolean' && typeof b === 'boolean') { comparison = a === b ? 0 : a ? 1 : -1; - } else if (!isNaN(a) && !isNaN(b)) { + } else if (!Number.isNaN(+a) && !Number.isNaN(+b)) { comparison = Number(a) - Number(b); } else if (Array.isArray(a) && Array.isArray(b)) { comparison = a.length - b.length; - } else if (!isNaN(Date.parse(a)) && !isNaN(Date.parse(b))) { + } else if (!Number.isNaN(Date.parse(a)) && !Number.isNaN(Date.parse(b))) { const dateA = new Date(a); const dateB = new Date(a); comparison = dateA.getTime() - dateB.getTime(); @@ -313,7 +313,11 @@ export default class AsyncIterableBuilder<Type> { } #nextPromise() { - this.#values.push(new Promise(resolve => (this.#resolve = resolve))); + this.#values.push( + new Promise(resolve => { + this.#resolve = resolve; + }), + ); } } diff --git a/src/libs/lit-helpers.ts b/src/libs/lit-helpers.ts index 83d828b0..31bba373 100644 --- a/src/libs/lit-helpers.ts +++ b/src/libs/lit-helpers.ts @@ -47,7 +47,7 @@ class SpreadDirective extends Directive { return noChange; } - let element; + let element: HTMLElement; prevCache.set(part, spreadData); if (part.type === PartType.ATTRIBUTE || part.type === PartType.PROPERTY) { diff --git a/src/libs/polyfills.ts b/src/libs/polyfills.ts index ce7f696f..c15d1e0a 100644 --- a/src/libs/polyfills.ts +++ b/src/libs/polyfills.ts @@ -3,7 +3,7 @@ if (!('flat' in Array.prototype)) { Object.defineProperty(Array.prototype, 'flat', { configurable: true, value: function flat(this: any[], depth = 1) { - depth = isNaN(depth) ? 1 : Number(depth); + depth = Number.isNaN(depth) ? 1 : Number(depth); if (depth === 0) return Array.prototype.slice.call(this); return Array.prototype.reduce.call<any, any[], any[]>( this, diff --git a/src/mixins/sorterMixin.ts b/src/mixins/sorterMixin.ts index 1b2f454d..726dae87 100644 --- a/src/mixins/sorterMixin.ts +++ b/src/mixins/sorterMixin.ts @@ -121,8 +121,8 @@ const SorterMixin = { }, sortValuesByKey(key: string, asc: boolean): Function { return function (a: object, b: object): number { - if (!a.hasOwnProperty(key)) return 1; - if (!b.hasOwnProperty(key)) return -1; + if (!Object.hasOwn(a, key)) return 1; + if (!Object.hasOwn(b, key)) return -1; const varA = a[key]; const varB = b[key]; diff --git a/src/mixins/widgetMixin.ts b/src/mixins/widgetMixin.ts index 15905e77..f8de0f6a 100644 --- a/src/mixins/widgetMixin.ts +++ b/src/mixins/widgetMixin.ts @@ -301,8 +301,8 @@ const WidgetMixin = { 'label', 'placeholder', 'class', - , - /* 'widget', */ 'required', + /* 'widget', */ + 'required', 'editable', 'autocomplete', 'upload-url', diff --git a/src/new-widgets/templateAdditionMixins/addableMixin.ts b/src/new-widgets/templateAdditionMixins/addableMixin.ts index e0b2a897..81384e5c 100644 --- a/src/new-widgets/templateAdditionMixins/addableMixin.ts +++ b/src/new-widgets/templateAdditionMixins/addableMixin.ts @@ -18,7 +18,7 @@ const AddableMixin = { const cleanAddableAttr: { [key: string]: string } = {}; for (let attr of addableAttr) cleanAddableAttr[attr.name.replace('addable-', '')] = attr.value; - if (!cleanAddableAttr.hasOwnProperty('data-src')) + if (!Object.hasOwn(cleanAddableAttr, 'data-src')) cleanAddableAttr['data-src'] = this.range; return cleanAddableAttr; }, diff --git a/src/new-widgets/templatesDependencies/rangeMixin.ts b/src/new-widgets/templatesDependencies/rangeMixin.ts index 40da95e9..fc980071 100644 --- a/src/new-widgets/templatesDependencies/rangeMixin.ts +++ b/src/new-widgets/templatesDependencies/rangeMixin.ts @@ -22,15 +22,13 @@ const RangeMixin = { callback: function (value: string) { if (value !== null) { const optional = value.trim().split(','); - let key; - let keyValue; const list = {}; optional.forEach(element => { if (element.includes('=')) { const option = element.trim().split('='); - key = option[1].trim(); - keyValue = option[0].trim(); + const key = option[1].trim(); + const keyValue = option[0].trim(); list[key] = keyValue; } else { const elem = element.trim(); diff --git a/src/new-widgets/valueTransformationMixins/dateMixin.ts b/src/new-widgets/valueTransformationMixins/dateMixin.ts index 5f690c4c..8c87824c 100644 --- a/src/new-widgets/valueTransformationMixins/dateMixin.ts +++ b/src/new-widgets/valueTransformationMixins/dateMixin.ts @@ -26,7 +26,7 @@ const DateMixin = { }, formatDateForInput(date: string) { let d = new Date(date); - if (isNaN(d.getTime())) throw new Error('Invalid date'); + if (Number.isNaN(d.getTime())) throw new Error('Invalid date'); let month = `${d.getMonth() + 1}`; let day = `${d.getDate()}`; let year = d.getFullYear(); diff --git a/src/widgets/baseWidget.ts b/src/widgets/baseWidget.ts index 1f988fc0..77849a29 100644 --- a/src/widgets/baseWidget.ts +++ b/src/widgets/baseWidget.ts @@ -156,10 +156,9 @@ export class BaseWidget extends HTMLElement { } set range(range) { (async () => { - this._listen( - range, - async () => (this._range = await store.getData(range, this.context)), - ); + this._listen(range, async () => { + this._range = await store.getData(range, this.context); + }); this._range = await store.getData(range, this.context); this.render(); })(); diff --git a/tsconfig.json b/tsconfig.json index cfe00896..4c7a46b4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es2018", + "target": "es2022", "module": "ESNext", "moduleResolution": "node", "allowJs": true, -- GitLab From 2242b0c1fb679cee2d50952ce13e00a2df9f5ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Sat, 16 Nov 2024 00:17:42 +0100 Subject: [PATCH 35/66] fix `lint/suspicious/noDoubleEquals` errors --- biome.jsonc | 1 - server.js | 2 +- src/components/solid-display.ts | 4 ++-- src/components/solid-form.ts | 2 +- src/components/solid-member-delete.ts | 2 +- src/components/solid-membership.ts | 2 +- src/libs/helpers.ts | 4 ++-- src/libs/store/store.ts | 2 +- src/mixins/attributeBinderMixin.ts | 4 ++-- src/mixins/highlighterMixin.ts | 2 +- src/mixins/serverPaginationMixin.ts | 2 +- src/mixins/sorterMixin.ts | 2 +- src/mixins/storeMixin.ts | 2 +- src/mixins/validationMixin.ts | 6 +++--- .../templatesDependencies/filterRangeFormMixin.ts | 2 +- src/widgets/baseWidget.ts | 14 ++++++++------ 16 files changed, 27 insertions(+), 26 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index 2d889b56..e8a26799 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -27,7 +27,6 @@ }, "suspicious": { "noExplicitAny": "off", - "noDoubleEquals": "off", "noAsyncPromiseExecutor": "off" } } diff --git a/server.js b/server.js index ee7d39ba..54e0fc04 100644 --- a/server.js +++ b/server.js @@ -102,7 +102,7 @@ function uniqID() { } function handleUpdate(req, rep) { - if (req.headers['content-type'] != 'application/ld+json') { + if (req.headers['content-type'] !== 'application/ld+json') { rep.status(500).send('Content not JSON'); return; } diff --git a/src/components/solid-display.ts b/src/components/solid-display.ts index b2814584..bb69c944 100644 --- a/src/components/solid-display.ts +++ b/src/components/solid-display.ts @@ -182,12 +182,12 @@ export const SolidDisplay = { attr.name.startsWith('link-text-') || attr.name.startsWith('target-src-') || attr.name.startsWith('data-label-') || - attr.name == 'extra-context' + attr.name === 'extra-context' ) attributes[attr.name] = attr.value; if (attr.name.startsWith('child-')) attributes[attr.name.replace(/^child-/, '')] = attr.value; - if (attr.name == 'next') { + if (attr.name === 'next') { attributes['role'] = 'button'; attributes['tabindex'] = '0'; } diff --git a/src/components/solid-form.ts b/src/components/solid-form.ts index 0b8ad40b..c9da74b5 100644 --- a/src/components/solid-form.ts +++ b/src/components/solid-form.ts @@ -104,7 +104,7 @@ export const SolidForm = { object && !object['@id'] && Array.isArray(object) && - value[predicate].length == 0 && + value[predicate].length === 0 && object.length > 0 ) { value[predicate] = object; diff --git a/src/components/solid-member-delete.ts b/src/components/solid-member-delete.ts index d26d30b0..6bb74b8f 100644 --- a/src/components/solid-member-delete.ts +++ b/src/components/solid-member-delete.ts @@ -96,7 +96,7 @@ export const SolidMemberDelete = { async deleteMembership() { let userSet = this.currentMembers.filter(value => { const userId = value['@id']; - if (userId == this.dataTargetSrc) return false; + if (userId === this.dataTargetSrc) return false; else return true; }); diff --git a/src/components/solid-membership.ts b/src/components/solid-membership.ts index 01c5eb05..f6ed6ff6 100644 --- a/src/components/solid-membership.ts +++ b/src/components/solid-membership.ts @@ -121,7 +121,7 @@ export const SolidMembership = { async leaveGroup() { let userSet = this.currentMembers.filter(value => { const userId = value['@id']; - if (userId == this.userId) return false; + if (userId === this.userId) return false; else return true; }); diff --git a/src/libs/helpers.ts b/src/libs/helpers.ts index a924d8a4..35846cff 100644 --- a/src/libs/helpers.ts +++ b/src/libs/helpers.ts @@ -161,7 +161,7 @@ function parseFieldsString(fields: string): string[] { } function findClosingBracketMatchIndex(str: string, pos: number) { - if (str[pos] != '(') throw new Error("No '(' at index " + pos); + if (str[pos] !== '(') throw new Error("No '(' at index " + pos); let depth = 1; for (let i = pos + 1; i < str.length; i++) { switch (str[i]) { @@ -169,7 +169,7 @@ function findClosingBracketMatchIndex(str: string, pos: number) { depth++; break; case ')': - if (--depth == 0) return i; + if (--depth === 0) return i; break; } } diff --git a/src/libs/store/store.ts b/src/libs/store/store.ts index 16ac1fc0..bb8378cf 100644 --- a/src/libs/store/store.ts +++ b/src/libs/store/store.ts @@ -276,7 +276,7 @@ class Store { // We have to add the server search and pagination attributes again here to the resource cache key if ( key === id && - resource['@type'] == + resource['@type'] === this.getExpandedPredicate('ldp:Container', clientContext) ) { // Add only pagination and search params to the original resource diff --git a/src/mixins/attributeBinderMixin.ts b/src/mixins/attributeBinderMixin.ts index a4bae624..2fa0847d 100644 --- a/src/mixins/attributeBinderMixin.ts +++ b/src/mixins/attributeBinderMixin.ts @@ -42,7 +42,7 @@ const AttributeBinderMixin = { for (let attr of Object.keys(newAttributes)) { // set attributes on element - if (oldAttributes[attr] == newAttributes[attr]) continue; // only if it changed + if (oldAttributes[attr] === newAttributes[attr]) continue; // only if it changed this.element.setAttribute(attr, newAttributes[attr]); } }, @@ -118,7 +118,7 @@ const AttributeBinderMixin = { .catch(() => { setTimeout(() => { ++retries; - if (retries == maxRetries) return reject(); + if (retries >= maxRetries) return reject(); this.retry(fn, ms).then(resolve); }, ms); }); diff --git a/src/mixins/highlighterMixin.ts b/src/mixins/highlighterMixin.ts index d6e39c82..9fd2142e 100644 --- a/src/mixins/highlighterMixin.ts +++ b/src/mixins/highlighterMixin.ts @@ -36,7 +36,7 @@ const HighlighterMixin = { sortHighlighted(resources, field, value) { for (let [index, res] of resources.entries()) { - if (res[field] && res[field] == value) { + if (res[field] && res[field] === value) { // put the current element at the beginning of the array resources.splice(0, 0, resources.splice(index, 1)[0]); // TODO : test with sort } diff --git a/src/mixins/serverPaginationMixin.ts b/src/mixins/serverPaginationMixin.ts index c4bc511e..83aee402 100644 --- a/src/mixins/serverPaginationMixin.ts +++ b/src/mixins/serverPaginationMixin.ts @@ -72,7 +72,7 @@ const ServerPaginationMixin = { async updateNavButtons(resourceId: string, index: string, variance: number) { this.element.querySelector("[data-id='prev']").disabled = this.currentOffset[index] <= 0; - // this.element.querySelector("[data-id='next']").disabled = await this.resource['ldp:contains'].length == 0; + // this.element.querySelector("[data-id='next']").disabled = await this.resource['ldp:contains'].length === 0; this.element.querySelector("[data-id='current']").innerText = this.getCurrentServedPage(resourceId, variance); }, diff --git a/src/mixins/sorterMixin.ts b/src/mixins/sorterMixin.ts index 726dae87..809baa4d 100644 --- a/src/mixins/sorterMixin.ts +++ b/src/mixins/sorterMixin.ts @@ -95,7 +95,7 @@ const SorterMixin = { // sorting data according to the defined value of sortingKey if (sortingKey) { let orderToSort = true; // set 'asc' by default - if (this.orderDesc || orderValueToSort == 'desc') orderToSort = false; + if (this.orderDesc || orderValueToSort === 'desc') orderToSort = false; resources = ( await Promise.all( resources.map(async resource => ({ diff --git a/src/mixins/storeMixin.ts b/src/mixins/storeMixin.ts index f7d4c40b..a28419a4 100644 --- a/src/mixins/storeMixin.ts +++ b/src/mixins/storeMixin.ts @@ -88,7 +88,7 @@ const StoreMixin = { async fetchData(value: string) { this.empty(); if (this.subscription) PubSub.unsubscribe(this.subscription); - if (!value || value == 'undefined') return; + if (!value || value === 'undefined') return; this.resourceId = value; if (this.nestedField) { diff --git a/src/mixins/validationMixin.ts b/src/mixins/validationMixin.ts index ee3477bd..138db14b 100644 --- a/src/mixins/validationMixin.ts +++ b/src/mixins/validationMixin.ts @@ -56,17 +56,17 @@ const ValidationMixin = { // Data directly submitted OR confirm dialog modal displayed if ( !this.confirmationType || - (this.confirmationType == 'confirm' && + (this.confirmationType === 'confirm' && confirm(this.confirmationMessage || this.t('validation.message'))) ) this.validateModal(); // Customisable dialog modal opened - if (this.confirmationType == 'dialog') { + if (this.confirmationType === 'dialog') { this.showModal(); } }, getModalDialog() { - if (this.confirmationType == 'dialog') { + if (this.confirmationType === 'dialog') { const quitDialog = () => { var dialog: any = document.getElementById(this.dialogID); if (dialog == null) return; diff --git a/src/new-widgets/templatesDependencies/filterRangeFormMixin.ts b/src/new-widgets/templatesDependencies/filterRangeFormMixin.ts index 3bd559dd..9d03620f 100644 --- a/src/new-widgets/templatesDependencies/filterRangeFormMixin.ts +++ b/src/new-widgets/templatesDependencies/filterRangeFormMixin.ts @@ -17,7 +17,7 @@ const FilterRangeFormMixin = { }, }, getDefaultValue(value) { - if (value == 'today') return new Date().toISOString().split('T')[0]; + if (value === 'today') return new Date().toISOString().split('T')[0]; return value; }, getValue() { diff --git a/src/widgets/baseWidget.ts b/src/widgets/baseWidget.ts index 77849a29..6ee20447 100644 --- a/src/widgets/baseWidget.ts +++ b/src/widgets/baseWidget.ts @@ -64,7 +64,7 @@ export class BaseWidget extends HTMLElement { get value() { if (this.dataHolder) { let values = this.dataHolder.map(element => { - if (element instanceof HTMLInputElement && element.type == 'checkbox') + if (element instanceof HTMLInputElement && element.type === 'checkbox') return element.checked; // if value is defined, push it in the array return this.getValueHolder(element).value; @@ -76,12 +76,12 @@ export class BaseWidget extends HTMLElement { } set value(value) { this._value = value; // ... store `value` in the widget - if (this._value == null || this._value == undefined) return; + if (this._value == null) return; if (this.dataHolder && this.dataHolder.length === 1) { // if one dataHolder in the widget... const element = this.getValueHolder(this.dataHolder[0]); - if (element.type == 'checkbox') { + if (element.type === 'checkbox') { element.checked = value; } else { element.value = value; // ... set `value` to the dataHolder element @@ -92,7 +92,7 @@ export class BaseWidget extends HTMLElement { // if multiple dataHolder in the widget ... this.dataHolder.forEach((el, index) => { const element = this.getValueHolder(el); - if (element.type == 'checkbox') { + if (element.type === 'checkbox') { element.checked = value ? value[index] : ''; } else { element.value = value ? value[index] : ''; @@ -212,14 +212,16 @@ export class BaseWidget extends HTMLElement { // selected options for multiple select selected = false; for await (let value of this._value['ldp:contains']) { - if (value['@id'] == element['@id']) { + if (value['@id'] === element['@id']) { selected = true; break; } } } else { // selected options for simple dropdowns - selected = this._value ? this._value['@id'] == element['@id'] : false; + selected = this._value + ? this._value['@id'] === element['@id'] + : false; } htmlRange += await evalTemplateString(this.childTemplate, { name: await element.name, -- GitLab From 72811bb6b670ec915f1ec02ca392eacdf5f31784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Sat, 16 Nov 2024 02:10:10 +0100 Subject: [PATCH 36/66] fix `lint/complexity` errors (partial) --- biome.jsonc | 6 +++++- cypress/e2e/e2e/filteredBy.cy.ts | 2 +- cypress/e2e/e2e/helpers.cy.ts | 4 ++-- cypress/e2e/e2e/solid-form-file.cy.ts | 12 ++++++------ cypress/e2e/unit/ComponentFactory.cy.ts | 2 +- cypress/e2e/unit/Compositor.cy.ts | 2 +- cypress/e2e/unit/helpers.cy.ts | 12 ++++++------ src/libs/Compositor.ts | 4 ++-- src/libs/Sib.ts | 2 +- src/libs/filter.ts | 2 +- src/libs/helpers.ts | 6 ++---- src/libs/interfaces.ts | 4 ++-- src/libs/polyfills.ts | 2 +- src/libs/store/store.ts | 10 ++++------ src/logger.ts | 4 ++-- src/mixins/interfaces.ts | 2 +- src/mixins/sorterMixin.ts | 2 +- src/solid-template-element.ts | 2 +- src/widgets/baseWidget.ts | 4 ++-- 19 files changed, 42 insertions(+), 42 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index e8a26799..c4bf1090 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -23,7 +23,11 @@ "all": false }, "complexity": { - "all": false + "useLiteralKeys": "off", + "noForEach": "off", + "noBannedTypes": "off", + "useOptionalChain": "off", + "noStaticOnlyClass": "off" }, "suspicious": { "noExplicitAny": "off", diff --git a/cypress/e2e/e2e/filteredBy.cy.ts b/cypress/e2e/e2e/filteredBy.cy.ts index 55c8d5e8..b5790490 100644 --- a/cypress/e2e/e2e/filteredBy.cy.ts +++ b/cypress/e2e/e2e/filteredBy.cy.ts @@ -1,4 +1,4 @@ -describe('simple Startin’blox e2e test', function () { +describe('simple Startin’blox e2e test', () => { it('check children count', () => { cy.visit('/examples/filtered.html'); cy.get('#filter1 input').type('ma#er'); // match "mayer" diff --git a/cypress/e2e/e2e/helpers.cy.ts b/cypress/e2e/e2e/helpers.cy.ts index e69b6400..4ae799a1 100644 --- a/cypress/e2e/e2e/helpers.cy.ts +++ b/cypress/e2e/e2e/helpers.cy.ts @@ -159,7 +159,7 @@ describe('helpers', function () { }); }); - describe('defineComponent', function () { + describe('defineComponent', () => { it('define my-component', () => { expect(win.customElements.get('my-component')).to.be.undefined; helpers.defineComponent('my-component', class extends HTMLElement {}); @@ -174,7 +174,7 @@ describe('helpers', function () { }); }); - describe('asyncQuerySelector', function () { + describe('asyncQuerySelector', () => { it('select an element already in document', async () => { const list = doc.querySelector('#async-qs ul')!; const list2 = await helpers.asyncQuerySelector('#async-qs ul'); diff --git a/cypress/e2e/e2e/solid-form-file.cy.ts b/cypress/e2e/e2e/solid-form-file.cy.ts index 5ed36ff8..4d6fad10 100644 --- a/cypress/e2e/e2e/solid-form-file.cy.ts +++ b/cypress/e2e/e2e/solid-form-file.cy.ts @@ -4,7 +4,7 @@ describe('solid-form-file test', { testIsolation: false }, function () { cy.visit('/examples/e2e/solid-form-file.html'); }); - it('upload file with solid-form-file', function () { + it('upload file with solid-form-file', () => { cy.get('#form-file [name=picture] input[type=file]').uploadFile( '../../fake-image.svg', ); @@ -13,7 +13,7 @@ describe('solid-form-file test', { testIsolation: false }, function () { }); }); - it('upload image with solid-form-file-image', function () { + it('upload image with solid-form-file-image', () => { cy.get('#form-image solid-form-image input[type=file]').uploadFile( '../../fake-image.svg', ); @@ -23,7 +23,7 @@ describe('solid-form-file test', { testIsolation: false }, function () { }); }); - it('resets the file', function () { + it('resets the file', () => { cy.get('#reset-file solid-form-file input[type=file]').uploadFile( '../../fake-image.svg', ); @@ -40,7 +40,7 @@ describe('solid-form-file test', { testIsolation: false }, function () { cy.get('#reset-file solid-form-file button').should('have.attr', 'hidden'); }); - it('resets the image', function () { + it('resets the image', () => { cy.get('#reset-image solid-form-image input[type=file]').uploadFile( '../../fake-image.svg', ); @@ -63,7 +63,7 @@ describe('solid-form-file test', { testIsolation: false }, function () { ); }); - it('handles required', function () { + it('handles required', () => { cy.get('#form-required-image solid-form-image input[type=text]').should( 'have.attr', 'required', @@ -82,7 +82,7 @@ describe('solid-form-file test', { testIsolation: false }, function () { ); }); - it('displays file name if source not empty', function () { + it('displays file name if source not empty', () => { cy.visit('/examples/e2e/solid-form-file.html'); // if not then page is not updated, and another file is uploaded from the prev test cy.get( '#form-file solid-form-file[name=picture] a[href="../../upload/fruits.jpg"]', diff --git a/cypress/e2e/unit/ComponentFactory.cy.ts b/cypress/e2e/unit/ComponentFactory.cy.ts index 9e6ed6a1..fa69a0d9 100644 --- a/cypress/e2e/unit/ComponentFactory.cy.ts +++ b/cypress/e2e/unit/ComponentFactory.cy.ts @@ -112,7 +112,7 @@ const Component = { }, }; -describe('Component factory', function () { +describe('Component factory', () => { it('expose html element', () => { const ComponentConstructor = ComponentFactory.build(Component); const component = new ComponentConstructor(document.createElement('p')); diff --git a/cypress/e2e/unit/Compositor.cy.ts b/cypress/e2e/unit/Compositor.cy.ts index 7e9c1c3b..2c3f9d47 100644 --- a/cypress/e2e/unit/Compositor.cy.ts +++ b/cypress/e2e/unit/Compositor.cy.ts @@ -92,7 +92,7 @@ const component = { }, }; -describe('Mixin Compositor', function () { +describe('Mixin Compositor', () => { it('merge mixin', () => { const result = Compositor.mergeMixin(component); expect(result.length).eq(2); diff --git a/cypress/e2e/unit/helpers.cy.ts b/cypress/e2e/unit/helpers.cy.ts index 3082859e..f6fd53bd 100644 --- a/cypress/e2e/unit/helpers.cy.ts +++ b/cypress/e2e/unit/helpers.cy.ts @@ -11,7 +11,7 @@ import { /** * uniqID */ -describe('uniqID', function () { +describe('uniqID', () => { it('returns an id', () => { let test = uniqID(); expect(test).to.match(/[_].{10}/g); @@ -30,7 +30,7 @@ describe('uniqID', function () { /** * stringToDom */ -describe('stringToDom', function () { +describe('stringToDom', () => { it('returns a fragment', () => { const fragment = stringToDom('<h1>Test element</h1>'); expect(fragment.constructor.name).to.eq('DocumentFragment'); @@ -54,7 +54,7 @@ describe('stringToDom', function () { /** * setDeepProperty */ -describe('setDeepProperty', function () { +describe('setDeepProperty', () => { it('set properties', () => { const object = { name: 'test', @@ -91,7 +91,7 @@ describe('setDeepProperty', function () { /** * parseFieldsString */ -describe('parseFieldsString', function () { +describe('parseFieldsString', () => { it('returns first level of fields', () => { const fields = 'field1, field2(field3,field4, field5( field6, field7) ), field8,field9'; @@ -108,7 +108,7 @@ describe('parseFieldsString', function () { /** * findClosingBracketMatchIndex */ -describe('findClosingBracketMatchIndex', function () { +describe('findClosingBracketMatchIndex', () => { it('throw error', () => { const fields = 'field1, field2(field3,field4, field5( field6, field7) ), field8,field9'; @@ -140,7 +140,7 @@ describe('findClosingBracketMatchIndex', function () { /** * evalTemplateString */ -describe('evalTemplateString', function () { +describe('evalTemplateString', () => { it('render template with values', async () => { const values = { val1: 'test 1', diff --git a/src/libs/Compositor.ts b/src/libs/Compositor.ts index 945b18a2..6f631c8d 100644 --- a/src/libs/Compositor.ts +++ b/src/libs/Compositor.ts @@ -56,7 +56,7 @@ export class Compositor { let attributes = {}; mixins.forEach(mixin => { - if (!!mixin.attributes) { + if (mixin.attributes) { attributes = { ...mixin.attributes, ...attributes }; } }); @@ -68,7 +68,7 @@ export class Compositor { let initialState = {}; mixins.forEach(mixin => { - if (!!mixin.initialState) { + if (mixin.initialState) { initialState = { ...mixin.initialState, ...initialState }; } }); diff --git a/src/libs/Sib.ts b/src/libs/Sib.ts index 419c721c..42b97e67 100644 --- a/src/libs/Sib.ts +++ b/src/libs/Sib.ts @@ -9,7 +9,7 @@ import type { export class Sib { public static register(componentDefinition: MixinStaticInterface): void { const component = ComponentFactory.build(componentDefinition); - const cls = this.toElement(component); + const cls = Sib.toElement(component); defineComponent(component.name, cls); } diff --git a/src/libs/filter.ts b/src/libs/filter.ts index 091148f8..5ff6608e 100644 --- a/src/libs/filter.ts +++ b/src/libs/filter.ts @@ -240,7 +240,7 @@ const matchFilter = async ( (targetIds.length === 0 && query.value !== '') ) { // console.log(`No targetIds found for ${resource['@id']} returning false`); - throw throwOn ? false : true; + throw !throwOn; } // console.log(`Do we have a match for ${resource['@id']} ?`, match); diff --git a/src/libs/helpers.ts b/src/libs/helpers.ts index 35846cff..66b3a591 100644 --- a/src/libs/helpers.ts +++ b/src/libs/helpers.ts @@ -10,6 +10,7 @@ function stringToDom(html: string): DocumentFragment { return template.content; } +const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor; async function evalTemplateString( str: string, variables: { [key: string]: any } = {}, @@ -17,9 +18,6 @@ async function evalTemplateString( const keys = Object.keys(variables); const values = keys.map(key => variables[key]); try { - const AsyncFunction = Object.getPrototypeOf( - async function () {}, - ).constructor; const func = AsyncFunction.call(null, ...keys, 'return `' + str + '`'); return await func(...values); } catch (e) { @@ -118,7 +116,7 @@ function loadScript(source: string) { } function domIsReady(): Promise<void> { - return new Promise(function (resolve) { + return new Promise(resolve => { if (document.readyState === 'complete') { resolve(); } else { diff --git a/src/libs/interfaces.ts b/src/libs/interfaces.ts index fed98505..5d7515b3 100644 --- a/src/libs/interfaces.ts +++ b/src/libs/interfaces.ts @@ -45,7 +45,7 @@ export interface ComponentInterface { export interface ComponentStaticInterface extends HasAttributesDefinitionInterface, HasInitialStateInterface { - name: String; + name: string; hooks: ArrayOfHooksInterface; methods: Map<string, Function>; @@ -79,7 +79,7 @@ export interface MixinStaticInterface HasMixinsInterface, HasInitialStateInterface, HasHooksInterface { - name: String; + name: string; } export interface LocationResourceInterface { diff --git a/src/libs/polyfills.ts b/src/libs/polyfills.ts index c15d1e0a..f79eb489 100644 --- a/src/libs/polyfills.ts +++ b/src/libs/polyfills.ts @@ -7,7 +7,7 @@ if (!('flat' in Array.prototype)) { if (depth === 0) return Array.prototype.slice.call(this); return Array.prototype.reduce.call<any, any[], any[]>( this, - function (acc: any[], cur: any) { + (acc: any[], cur: any) => { if (Array.isArray(cur)) { acc.push.apply(acc, flat.call(cur, depth - 1)); } else { diff --git a/src/libs/store/store.ts b/src/libs/store/store.ts index bb8378cf..fc1ad150 100644 --- a/src/libs/store/store.ts +++ b/src/libs/store/store.ts @@ -45,7 +45,7 @@ class Store { cache: Map<string, any>; subscriptionIndex: Map<string, any>; // index of all the containers per resource subscriptionVirtualContainersIndex: Map<string, any>; // index of all the containers per resource - loadingList: Set<String>; + loadingList: Set<string>; headers: object; fetch: Promise<any> | undefined; session: Promise<any> | undefined; @@ -184,9 +184,7 @@ class Store { // anonymous if (options.headers) options.headers = this._convertHeaders(options.headers); - return fetch(iri, options).then(function (response) { - return response; - }); + return fetch(iri, options).then(response => response); } } @@ -682,8 +680,8 @@ class Store { localStorage.setItem('language', selectedLanguageCode); } - resolveResource = function (id: string, resolve) { - const handler = function (event) { + resolveResource = (id: string, resolve) => { + const handler = event => { if (event.detail.id === id) { if (event.detail.resource) { resolve(event.detail.resource); diff --git a/src/logger.ts b/src/logger.ts index 59d3e178..8113e513 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -32,9 +32,9 @@ function formatMessage(level, messages) { var originalFactory = log.methodFactory; -log.methodFactory = function (methodName, logLevel, loggerName) { +log.methodFactory = (methodName, logLevel, loggerName) => { const rawMethod = originalFactory(methodName, logLevel, loggerName); - return function (...messages) { + return (...messages) => { rawMethod(formatMessage(methodName, messages)); }; }; diff --git a/src/mixins/interfaces.ts b/src/mixins/interfaces.ts index 61a51c7d..0fca9342 100644 --- a/src/mixins/interfaces.ts +++ b/src/mixins/interfaces.ts @@ -5,7 +5,7 @@ export enum WidgetType { } export interface WidgetInterface { - tagName: String; + tagName: string; type: WidgetType; } diff --git a/src/mixins/sorterMixin.ts b/src/mixins/sorterMixin.ts index 809baa4d..47d6c832 100644 --- a/src/mixins/sorterMixin.ts +++ b/src/mixins/sorterMixin.ts @@ -120,7 +120,7 @@ const SorterMixin = { return this.orderByRandom !== null; }, sortValuesByKey(key: string, asc: boolean): Function { - return function (a: object, b: object): number { + return (a: object, b: object): number => { if (!Object.hasOwn(a, key)) return 1; if (!Object.hasOwn(b, key)) return -1; diff --git a/src/solid-template-element.ts b/src/solid-template-element.ts index f427c5ad..b4facf2b 100644 --- a/src/solid-template-element.ts +++ b/src/solid-template-element.ts @@ -11,7 +11,7 @@ export default class SolidTemplateElement extends HTMLElement { this.initProps(); } static get observedAttributes() { - return Object.values(this.propsDefinition); + return Object.values(SolidTemplateElement.propsDefinition); } static get propsDefinition(): { [key: string]: any } { diff --git a/src/widgets/baseWidget.ts b/src/widgets/baseWidget.ts index 6ee20447..c5244107 100644 --- a/src/widgets/baseWidget.ts +++ b/src/widgets/baseWidget.ts @@ -31,8 +31,8 @@ export class BaseWidget extends HTMLElement { escapedValue: this.escapedValue, range: await this.htmlRange, multiple: this.multiple, - editable: this.editable === '' ? true : false, - required: this.required === '' ? true : false, + editable: this.editable === '', + required: this.required === '', }); this.addEditButtons(); -- GitLab From 3fc3ce3d5e0dbaa9edcd8db5e678d09fb68ba3f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Tue, 19 Nov 2024 02:57:22 +0100 Subject: [PATCH 37/66] fix `lint/style` errors (partial) --- biome.jsonc | 3 -- cypress/e2e/e2e/order-by.cy.ts | 6 ++-- cypress/e2e/unit/helpers.cy.ts | 6 ++-- cypress/e2e/unit/store.cy.ts | 2 +- src/components/solid-display.ts | 6 ++-- src/components/solid-form-search.ts | 6 ++-- src/components/solid-form.ts | 32 ++++++++--------- src/components/solid-lang.ts | 2 +- src/components/solid-member-add.ts | 9 +++-- src/components/solid-member-delete.ts | 9 +++-- src/components/solid-membership.ts | 13 ++++--- src/components/solid-table.ts | 10 +++--- src/libs/filter.ts | 6 ++-- src/libs/helpers.ts | 12 +++---- src/libs/interfaces.ts | 13 ++++--- src/libs/lit-helpers.ts | 23 ++++++++----- src/libs/store/custom-getter.ts | 14 ++++---- src/libs/store/store.ts | 14 ++++---- src/logger.ts | 2 +- src/mixins/attributeBinderMixin.ts | 12 +++---- src/mixins/contextMixin.ts | 2 +- src/mixins/counterMixin.ts | 2 +- src/mixins/federationMixin.ts | 2 +- src/mixins/filterMixin.ts | 2 +- src/mixins/grouperMixin.ts | 8 ++--- src/mixins/highlighterMixin.ts | 6 ++-- src/mixins/listMixin.ts | 2 +- src/mixins/paginateMixin.ts | 4 +-- src/mixins/requiredMixin.ts | 8 ++--- src/mixins/serverPaginationMixin.ts | 6 ++-- src/mixins/sorterMixin.ts | 2 +- src/mixins/storeMixin.ts | 2 +- src/mixins/widgetMixin.ts | 34 +++++++++---------- .../callbackMixins/autocompletionMixin.ts | 2 +- .../callbackMixins/richtextMixin.ts | 4 +-- .../templateAdditionMixins/addableMixin.ts | 4 +-- .../templateAdditionMixins/labelLastMixin.ts | 2 +- .../templateAdditionMixins/labelMixin.ts | 2 +- .../templatesDependencies/editableMixin.ts | 2 +- .../multipleFormMixin.ts | 10 +++--- .../multipleselectFormMixin.ts | 4 +-- .../templatesDependencies/rangeMixin.ts | 2 +- .../autolinkMixin.ts | 2 +- .../valueTransformationMixins/dateMixin.ts | 6 ++-- .../dateTimeMixin.ts | 2 +- .../markdownMixin.ts | 2 +- .../multilineMixin.ts | 2 +- .../valueTransformationMixins/oembedMixin.ts | 2 +- src/solid-template-element.ts | 6 ++-- src/widgets/baseWidget.ts | 8 ++--- src/widgets/widget-factory.ts | 2 +- 51 files changed, 178 insertions(+), 166 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index c4bf1090..184a3aa7 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -19,9 +19,6 @@ "enabled": true, "rules": { "recommended": true, - "style": { - "all": false - }, "complexity": { "useLiteralKeys": "off", "noForEach": "off", diff --git a/cypress/e2e/e2e/order-by.cy.ts b/cypress/e2e/e2e/order-by.cy.ts index 5565ce08..4f17cf30 100644 --- a/cypress/e2e/e2e/order-by.cy.ts +++ b/cypress/e2e/e2e/order-by.cy.ts @@ -112,12 +112,14 @@ describe('order-by', { testIsolation: false }, function () { cy.get('@list') .find('> div > solid-display') .then($div => { - let currentOrder = Array.from($div.map((_index, el) => el.dataset.src)); + const currentOrder = Array.from( + $div.map((_index, el) => el.dataset.src), + ); cy.get('#reloadList').click(); cy.get('@list') .find('> div > solid-display') .then($newDiv => { - let newOrder = Array.from( + const newOrder = Array.from( $newDiv.map((_index, el) => el.dataset.src), ); expect(currentOrder).to.not.include.ordered.members(newOrder); diff --git a/cypress/e2e/unit/helpers.cy.ts b/cypress/e2e/unit/helpers.cy.ts index f6fd53bd..a616652f 100644 --- a/cypress/e2e/unit/helpers.cy.ts +++ b/cypress/e2e/unit/helpers.cy.ts @@ -13,16 +13,16 @@ import { */ describe('uniqID', () => { it('returns an id', () => { - let test = uniqID(); + const test = uniqID(); expect(test).to.match(/[_].{10}/g); }); it('returns a different id 50 times in a row', () => { - let ids: string[] = []; + const ids: string[] = []; const arraySize = 50; for (let index = 0; index < arraySize; index++) { ids.push(uniqID()); } - let noDuplicates = [...new Set(ids)]; + const noDuplicates = [...new Set(ids)]; expect(noDuplicates.length).to.eq(arraySize); }); }); diff --git a/cypress/e2e/unit/store.cy.ts b/cypress/e2e/unit/store.cy.ts index dae5295e..d2646dc3 100644 --- a/cypress/e2e/unit/store.cy.ts +++ b/cypress/e2e/unit/store.cy.ts @@ -58,7 +58,7 @@ describe('store', { testIsolation: false }, function () { '@context': 'https://cdn.startinblox.com/owl/context.jsonld', }; await store.setLocalData(dataToSave1, url); - let dataRead1 = await store.getData(url); + const dataRead1 = await store.getData(url); expect(await dataRead1!['foo']).eq('bar'); store.clearCache(url); }); diff --git a/src/components/solid-display.ts b/src/components/solid-display.ts index bb69c944..ddf5ea60 100644 --- a/src/components/solid-display.ts +++ b/src/components/solid-display.ts @@ -15,7 +15,7 @@ import { spread } from '../libs/lit-helpers'; import { html, render } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; -import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; import { trackRenderAsync } from '../logger'; export const SolidDisplay = { @@ -111,7 +111,7 @@ export const SolidDisplay = { * @param attributes */ getChildTemplate(resourceId: string, attributes: object) { - let template = html` + const template = html` <solid-display data-src=${resourceId} @click=${(event: Event) => this.dispatchSelect(event, resourceId)} @@ -167,7 +167,7 @@ export const SolidDisplay = { */ getChildAttributes() { const attributes: { [key: string]: string } = {}; - for (let attr of this.element.attributes) { + for (const attr of this.element.attributes) { //copy widget and value attributes if ( attr.name.startsWith('value-') || diff --git a/src/components/solid-form-search.ts b/src/components/solid-form-search.ts index d5ea377e..340d4148 100644 --- a/src/components/solid-form-search.ts +++ b/src/components/solid-form-search.ts @@ -82,7 +82,7 @@ export const SolidFormSearch = { }); return values; }, - getWidget(field: string, isSet: boolean = false): WidgetInterface { + getWidget(field: string, isSet = false): WidgetInterface { let tagName = ''; // If auto-range-[field] exists, create range-[field] and sets its value if ( @@ -128,7 +128,7 @@ export const SolidFormSearch = { async updateAutoRanges() { for (const attr of (this.element as Element).attributes) { if (!attr['name'].startsWith('auto-range-')) continue; - let fieldName = + const fieldName = attr.value !== '' ? attr.value : attr['name'].replace('auto-range-', ''); @@ -176,7 +176,7 @@ export const SolidFormSearch = { async inputChange(input: EventTarget): Promise<void> { // FIXME: Improve this as we need to support more than input and single select. // What about multiple select, checkboxes, radio buttons, etc? - let parentElementLabel = ( + const parentElementLabel = ( input as HTMLInputElement )?.parentElement?.getAttribute('label'); try { diff --git a/src/components/solid-form.ts b/src/components/solid-form.ts index c9da74b5..60d69cb8 100644 --- a/src/components/solid-form.ts +++ b/src/components/solid-form.ts @@ -82,9 +82,9 @@ export const SolidForm = { return !('@id' in formValue); }, async getFormValue() { - let value = this.value; + const value = this.value; if (this.resource && !this.resource.isContainer?.()) { - for (let predicate of Object.keys(this.value)) { + for (const predicate of Object.keys(this.value)) { // add @id for nested resources let object = await this.resource[predicate]; // edge-case where object is null because predicate needs to be expanded manually (arrays) @@ -113,7 +113,7 @@ export const SolidForm = { } return transformArrayToContainer(value); }, - getWidget(field: string, isSet: boolean = false): WidgetInterface { + getWidget(field: string, isSet = false): WidgetInterface { let tagName = ''; const widgetAttribute = this.element.getAttribute('widget-' + field); @@ -195,10 +195,10 @@ export const SolidForm = { if (!this.isCreationForm(formValue) && this.isSavingAutomatically) this.submitForm(); // if autosave, submitForm }, - displayErrorMessage(errors: [string, any][], errorFullName: string = '') { + displayErrorMessage(errors: [string, any][], errorFullName = '') { errors.forEach((member: [string, any]) => { - let errorNextName: string = Object.values(member)[0]; - let subErrorName = + const errorNextName: string = Object.values(member)[0]; + const subErrorName = errorFullName === '' ? errorNextName : errorFullName.concat('.' + errorNextName); @@ -209,15 +209,15 @@ export const SolidForm = { else errorFieldName = errorNextName; if (errorFieldName) { - let formField = this.element.querySelector( + const formField = this.element.querySelector( `[name="${errorFieldName}"]`, ); if (formField) { formField.classList.add('error'); - let errorParagraph = document.createElement('p'); + const errorParagraph = document.createElement('p'); if (Array.isArray(Object.values(member)[1]) === true) { Object.values(member)[1].forEach(error => { - let errorText = document.createElement('p'); + const errorText = document.createElement('p'); errorText.textContent = error; errorParagraph.appendChild(errorText); }); @@ -228,12 +228,12 @@ export const SolidForm = { )) { if (Array.isArray(value)) { value.forEach(error => { - let errorText = document.createElement('p'); + const errorText = document.createElement('p'); errorText.textContent = error; errorParagraph.appendChild(errorText); }); } else if (typeof value === 'string') { - let errorText = document.createElement('p'); + const errorText = document.createElement('p'); errorText.textContent = value; errorParagraph.appendChild(errorText); } @@ -247,15 +247,15 @@ export const SolidForm = { } if (!Array.isArray(Object.values(member)[1]) === true) { - let objectErrors = Object.values(member)[1]; - let subErrors = Object.entries(objectErrors); + const objectErrors = Object.values(member)[1]; + const subErrors = Object.entries(objectErrors); this.displayErrorMessage(subErrors, subErrorName); } }); }, empty(): void {}, showError(e: object) { - let errors = Object.entries(e).filter( + const errors = Object.entries(e).filter( field => !field[0].startsWith('@context'), ); this.displayErrorMessage(errors); @@ -266,10 +266,10 @@ export const SolidForm = { if (parentElement) render(errorTemplate, parentElement); }, hideError() { - let formErrors = this.element.querySelectorAll('.error-message'); + const formErrors = this.element.querySelectorAll('.error-message'); if (formErrors) formErrors.forEach(error => error.remove()); - let errorFields = this.element.querySelectorAll('.error'); + const errorFields = this.element.querySelectorAll('.error'); if (errorFields) errorFields.forEach(errorField => errorField.classList.remove('error')); diff --git a/src/components/solid-lang.ts b/src/components/solid-lang.ts index 4bb48967..79e1a4f3 100644 --- a/src/components/solid-lang.ts +++ b/src/components/solid-lang.ts @@ -27,7 +27,7 @@ export const SolidLang = { }, render() { - let template = html`<button @click=${this.languageLoader.bind(this)}>${this.dataLabel}</button>`; + const template = html`<button @click=${this.languageLoader.bind(this)}>${this.dataLabel}</button>`; render(template, this.element); }, diff --git a/src/components/solid-member-add.ts b/src/components/solid-member-add.ts index 69bce70a..03285bb4 100644 --- a/src/components/solid-member-add.ts +++ b/src/components/solid-member-add.ts @@ -60,7 +60,7 @@ export const SolidMemberAdd = { }, async addMembership() { this.currentMembers.push(JSON.parse(this.dataTargetSrc)); - let currentRes = { + const currentRes = { '@context': this.context, user_set: this.currentMembers, }; @@ -99,7 +99,10 @@ export const SolidMemberAdd = { if (!this.resource) return; // Check if current user is member of this group ? - let memberPredicate = store.getExpandedPredicate('user_set', base_context); + const memberPredicate = store.getExpandedPredicate( + 'user_set', + base_context, + ); // Here we now retrieve an array of proxy, when we would like an array of @ids only this.currentMembers = await this.resource[memberPredicate]; @@ -111,7 +114,7 @@ export const SolidMemberAdd = { return { '@id': member['@id'] }; }); - let button = html` + const button = html` <solid-ac-checker data-src="${this.dataSrc}" permission="acl:Write" > diff --git a/src/components/solid-member-delete.ts b/src/components/solid-member-delete.ts index 6bb74b8f..935ddcef 100644 --- a/src/components/solid-member-delete.ts +++ b/src/components/solid-member-delete.ts @@ -63,7 +63,10 @@ export const SolidMemberDelete = { if (!this.resource) return; // Check if current user is member of this group ? - let memberPredicate = store.getExpandedPredicate('user_set', base_context); + const memberPredicate = store.getExpandedPredicate( + 'user_set', + base_context, + ); this.currentMembers = await this.resource[memberPredicate]; if (!Array.isArray(this.currentMembers)) { @@ -94,13 +97,13 @@ export const SolidMemberDelete = { this.performAction(); // In validationMixin, method defining what to do according to the present attributes }, async deleteMembership() { - let userSet = this.currentMembers.filter(value => { + const userSet = this.currentMembers.filter(value => { const userId = value['@id']; if (userId === this.dataTargetSrc) return false; else return true; }); - let currentRes = { + const currentRes = { '@context': this.context, user_set: userSet, }; diff --git a/src/components/solid-membership.ts b/src/components/solid-membership.ts index f6ed6ff6..3090d3e3 100644 --- a/src/components/solid-membership.ts +++ b/src/components/solid-membership.ts @@ -52,7 +52,7 @@ export const SolidMembership = { if (!store.session) return; // Retrieve the current user from the current store authenticated session - let currentUserSession = await store.session; + const currentUserSession = await store.session; if (!currentUserSession) return; if (!this.dataTargetSrc) this.userId = await currentUserSession.webId; @@ -65,7 +65,10 @@ export const SolidMembership = { if (!this.resource) return; // Check if current user is member of this group ? - let memberPredicate = store.getExpandedPredicate('user_set', base_context); + const memberPredicate = store.getExpandedPredicate( + 'user_set', + base_context, + ); this.currentMembers = await this.resource[memberPredicate]; if (!Array.isArray(this.currentMembers)) { @@ -97,7 +100,7 @@ export const SolidMembership = { }, async joinGroup() { this.currentMembers.push({ '@id': this.userId }); - let currentRes = { + const currentRes = { '@context': this.context, user_set: this.currentMembers, }; @@ -119,13 +122,13 @@ export const SolidMembership = { }); }, async leaveGroup() { - let userSet = this.currentMembers.filter(value => { + const userSet = this.currentMembers.filter(value => { const userId = value['@id']; if (userId === this.userId) return false; else return true; }); - let currentRes = { + const currentRes = { '@context': this.context, user_set: userSet, }; diff --git a/src/components/solid-table.ts b/src/components/solid-table.ts index 3f661eee..2cd7f9b8 100644 --- a/src/components/solid-table.ts +++ b/src/components/solid-table.ts @@ -16,7 +16,7 @@ import { RequiredMixin } from '../mixins/requiredMixin'; import { html, render } from 'lit'; import { until } from 'lit/directives/until.js'; import { spread } from '../libs/lit-helpers'; -import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; import { trackRenderAsync } from '../logger'; export const SolidTable = { @@ -132,7 +132,7 @@ export const SolidTable = { 'title', 'widget', ]; - for (let attr of formWidgetAttributes) + for (const attr of formWidgetAttributes) this.addToAttributes(`${attr}-${field}`, `${attr}-${field}`, attributes); const formAttributes = [ @@ -141,7 +141,7 @@ export const SolidTable = { 'submit-button', 'next', ]; - for (let attr of formAttributes) + for (const attr of formAttributes) this.addToAttributes(`${attr}-${field}`, attr, attributes); return html` @@ -159,7 +159,7 @@ export const SolidTable = { * @param fields */ getHeader(fields: string[]) { - let template = html` + const template = html` <tr> ${this.selectable !== null ? html`<th><input type="checkbox" @change="${this.selectAll.bind(this)}" /></th>` : ''} ${fields.map((field: string) => html`<th>${this.element.hasAttribute('label-' + field) ? this.element.getAttribute('label-' + field) : field}</th>`)} @@ -174,7 +174,7 @@ export const SolidTable = { */ async getChildTemplate(resourceId: string, fields) { const resource = await store.getData(resourceId, this.context); - let template = html` + const template = html` <tr data-resource="${resourceId}"> ${this.selectable !== null ? html`<td><input type="checkbox" data-selection /></td>` : ''} ${fields.map((field: string) => html`<td>${until(this.createCellWidget(field, resource))}</td>`)} diff --git a/src/libs/filter.ts b/src/libs/filter.ts index 5ff6608e..ae66b07f 100644 --- a/src/libs/filter.ts +++ b/src/libs/filter.ts @@ -14,7 +14,7 @@ import type { Query, SearchQuery } from './interfaces'; */ const isSet = (field: string, fields: string): boolean => { if (!fields) return false; - let foundSets = fields.match(getSetRegexp(field)); + const foundSets = fields.match(getSetRegexp(field)); return foundSets ? foundSets.length > 0 : false; }; /** @@ -292,7 +292,7 @@ const matchFilters = async ( try { await Promise.all( filterNames.map(async filter => { - let match = await matchFilter( + const match = await matchFilter( resource, filter, filters[filter], @@ -330,7 +330,7 @@ const searchInResources = async ( window.cachePropsSearchFilter = {}; return Promise.all( resources.map(async resource => { - let match = await matchFilters( + const match = await matchFilters( resource, filters, filterNames, diff --git a/src/libs/helpers.ts b/src/libs/helpers.ts index 66b3a591..65a61f3f 100644 --- a/src/libs/helpers.ts +++ b/src/libs/helpers.ts @@ -96,7 +96,7 @@ function relativeSource(source: string) { const e = new Error(); if (!e.stack) return source; const f2 = e.stack.split('\n').filter(l => l.includes(':'))[2]; - let line = f2.match(/[a-z]+:.*$/); + const line = f2.match(/[a-z]+:.*$/); if (!line) return source; const calledFile = line[0].replace(/(\:[0-9]+){2}\)?$/, ''); source = new URL(source, calledFile).href; @@ -144,8 +144,8 @@ function parseFieldsString(fields: string): string[] { // remove all sets from fields while (fields.indexOf('(') > 0) { - let firstBracket = fields.indexOf('('); - let noset = fields.substring( + const firstBracket = fields.indexOf('('); + const noset = fields.substring( firstBracket, findClosingBracketMatchIndex(fields, firstBracket) + 1, ); @@ -255,7 +255,7 @@ function generalComparator(a, b, order = 'asc') { function transformArrayToContainer(resource: object) { const newValue = { ...resource }; - for (let predicate of Object.keys(newValue)) { + for (const predicate of Object.keys(newValue)) { // iterate over all properties const predicateValue = newValue[predicate]; if (!predicateValue || typeof predicateValue !== 'object') continue; // undefined or literal, do nothing @@ -305,7 +305,7 @@ export default class AsyncIterableBuilder<Type> { } } - #next(value: Type, done: boolean = false) { + #next(value: Type, done = false) { this.#resolve({ value, done }); this.#nextPromise(); } @@ -319,7 +319,7 @@ export default class AsyncIterableBuilder<Type> { } } -import { +import type { AsyncQuerySelectorAllType, AsyncQuerySelectorType, } from './async-query-selector-types'; diff --git a/src/libs/interfaces.ts b/src/libs/interfaces.ts index 5d7515b3..9321971d 100644 --- a/src/libs/interfaces.ts +++ b/src/libs/interfaces.ts @@ -1,4 +1,4 @@ -import { Profiler } from '../logger'; +import type { Profiler } from '../logger'; export interface AccessorStaticInterface { [key: string]: { @@ -13,9 +13,10 @@ export interface ArrayOfHooksInterface { detached: HookInterface[]; } -export interface AttributeChangedCallbackInterface { - (newValue: any, oldValue: any): void; -} +export type AttributeChangedCallbackInterface = ( + newValue: any, + oldValue: any, +) => void; export interface AttributeDefinitionInterface { type?: any; @@ -70,9 +71,7 @@ export interface HasMixinsInterface { use?: MixinStaticInterface[] | undefined; } -export interface HookInterface { - (): void; -} +export type HookInterface = () => void; export interface MixinStaticInterface extends HasAttributesDefinitionInterface, diff --git a/src/libs/lit-helpers.ts b/src/libs/lit-helpers.ts index 31bba373..0d4730f6 100644 --- a/src/libs/lit-helpers.ts +++ b/src/libs/lit-helpers.ts @@ -5,17 +5,22 @@ import { html, - TemplateResult, + type TemplateResult, noChange, - ChildPart, - AttributePart, - BooleanAttributePart, - EventPart, - PropertyPart, - ElementPart, + type ChildPart, + type AttributePart, + type BooleanAttributePart, + type EventPart, + type PropertyPart, + type ElementPart, } from 'lit'; -import { directive, Directive, PartInfo, PartType } from 'lit/directive.js'; +import { + directive, + Directive, + type PartInfo, + PartType, +} from 'lit/directive.js'; type SpreadPartType = | ChildPart @@ -167,7 +172,7 @@ export function preHTML( let cachedStrings = templateStringsCache.get(strings); if (cachedStrings) { - for (let cached of cachedStrings) { + for (const cached of cachedStrings) { const { needlessValues } = cached; const isSame = needlessValues.every(nv => values[nv.index] === nv.value); diff --git a/src/libs/store/custom-getter.ts b/src/libs/store/custom-getter.ts index baca2655..7e8fcccd 100644 --- a/src/libs/store/custom-getter.ts +++ b/src/libs/store/custom-getter.ts @@ -19,7 +19,7 @@ export class CustomGetter { resource: object, clientContext: object, serverContext: object, - parentId: string = '', + parentId = '', serverPagination: object = {}, serverSearch: object = {}, ) { @@ -51,7 +51,7 @@ export class CustomGetter { // Specific case where the predicates is a full IRI, avoid splitting it on the dot notation try { - let isUrl = new URL(path); + const isUrl = new URL(path); // My goal is to be able to solve user['circles.ldp:contains'] on the fly // If we do not check the url protocol, then it is considered valid if (!isUrl.protocol.startsWith('http')) @@ -62,7 +62,7 @@ export class CustomGetter { if (!resources) return undefined; if (!Array.isArray(resources)) resources = [resources]; // convert to array if compacted to 1 resource - let result = resources + const result = resources ? resources.map((res: object) => { let resource: any = store.get(res['@id']); if (resource) return resource; @@ -125,7 +125,7 @@ export class CustomGetter { } if (!value || !value['@id']) return undefined; - let resource = await this.getResource( + const resource = await this.getResource( value['@id'], { ...this.clientContext, ...this.serverContext }, this.parentId || this.resourceId, @@ -176,7 +176,7 @@ export class CustomGetter { id: string, context: object, iriParent: string, - forceFetch: boolean = false, + forceFetch = false, ): Promise<Resource | null> { if (id.startsWith('_:b')) return store.get(id + iriParent); // anonymous node = get from cache return store.getData(id, context, iriParent, undefined, forceFetch); @@ -237,7 +237,7 @@ export class CustomGetter { if (!children) return null; if (!Array.isArray(children)) children = [children]; // convert to array if compacted to 1 resource - let result = children + const result = children ? children.map((res: object) => { let resource: any = store.get(res['@id']); if (resource) return resource; @@ -274,7 +274,7 @@ export class CustomGetter { * @param prop */ isFullResource(): boolean { - let propertiesKeys = Object.keys(this.resource).filter( + const propertiesKeys = Object.keys(this.resource).filter( p => !p.startsWith('@'), ); if (this.resource['@id'].startsWith('_:b')) return true; // anonymous node = considered as always full diff --git a/src/libs/store/store.ts b/src/libs/store/store.ts index fc1ad150..a033aa7e 100644 --- a/src/libs/store/store.ts +++ b/src/libs/store/store.ts @@ -84,7 +84,7 @@ class Store { context: any = {}, parentId = '', localData?: object, - forceFetch: boolean = false, + forceFetch = false, serverPagination?: ServerPaginationOptions, serverSearch?: ServerSearchOptions, ): Promise<Resource | null> { @@ -260,8 +260,8 @@ class Store { const compactedResources: any[] = await Promise.all( flattenedResources.map(r => jsonld.compact(r, {})), ); - for (let resource of compactedResources) { - let id = resource['@id'] || resource['id']; + for (const resource of compactedResources) { + const id = resource['@id'] || resource['id']; let key = resource['@id'] || resource['id']; if (!key) console.log('No key or id for resource:', resource); @@ -345,7 +345,7 @@ class Store { */ subscribeChildren(container: CustomGetter, containerId: string) { if (!container['ldp:contains']) return; - for (let res of container['ldp:contains']) { + for (const res of container['ldp:contains']) { this.subscribeResourceTo(containerId, res['@id'] || res['id']); } } @@ -433,9 +433,9 @@ class Store { async getNestedResources(resource: object, id: string) { const cachedResource = store.get(id); if (!cachedResource || cachedResource.isContainer?.()) return []; - let nestedProperties: any[] = []; + const nestedProperties: any[] = []; const excludeKeys = ['@context']; - for (let p of Object.keys(resource)) { + for (const p of Object.keys(resource)) { if ( resource[p] && typeof resource[p] === 'object' && @@ -648,7 +648,7 @@ class Store { let iri = ContextParser.expandTerm(id, context); // expand if reduced ids if (parentId && !parentId.startsWith('store://local')) { // and get full URL from parent caller for local files - let parentIri = new URL(parentId, document.location.href).href; + const parentIri = new URL(parentId, document.location.href).href; iri = new URL(iri, parentIri).href; } else { iri = new URL(iri, document.location.href).href; diff --git a/src/logger.ts b/src/logger.ts index 8113e513..b80e40cc 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -138,7 +138,7 @@ export class Profiler { totalExecutionTime: 0, lastExecutionTime: 0, averageExecutionTime: 0, - minExecutionTime: Infinity, + minExecutionTime: Number.POSITIVE_INFINITY, maxExecutionTime: 0, }; } diff --git a/src/mixins/attributeBinderMixin.ts b/src/mixins/attributeBinderMixin.ts index 2fa0847d..6e2aec83 100644 --- a/src/mixins/attributeBinderMixin.ts +++ b/src/mixins/attributeBinderMixin.ts @@ -14,7 +14,7 @@ const AttributeBinderMixin = { * Reset attributes values */ resetAttributesData() { - for (let attr of Object.keys(this.bindedAttributes)) { + for (const attr of Object.keys(this.bindedAttributes)) { this.element.setAttribute(attr, this.bindedAttributes[attr]); } }, @@ -40,7 +40,7 @@ const AttributeBinderMixin = { this.resource, ); // generate new attributes - for (let attr of Object.keys(newAttributes)) { + for (const attr of Object.keys(newAttributes)) { // set attributes on element if (oldAttributes[attr] === newAttributes[attr]) continue; // only if it changed this.element.setAttribute(attr, newAttributes[attr]); @@ -56,14 +56,14 @@ const AttributeBinderMixin = { async transformAttributes(attributes: object, resource: Resource) { const isContainer = resource && resource.isContainer?.(); - for (let attr of Object.keys(attributes)) { + for (const attr of Object.keys(attributes)) { const value = attributes[attr]; // Avoid error if value is a number if (typeof value === 'string') { // Replace attribute value if (!isContainer && resource && value.startsWith('store://resource')) { // RESOURCE - let path = value.replace('store://resource.', ''); + const path = value.replace('store://resource.', ''); attributes[attr] = resource ? await resource[path] : ''; } else if ( isContainer && @@ -71,7 +71,7 @@ const AttributeBinderMixin = { value.startsWith('store://container') ) { // CONTAINER - let path = value.replace('store://container.', ''); + const path = value.replace('store://container.', ''); attributes[attr] = resource ? await resource[path] : ''; } else if (value.startsWith('store://user')) { // USER @@ -86,7 +86,7 @@ const AttributeBinderMixin = { attributes[attr] = ''; continue; } - let path = value.replace('store://user.', ''); + const path = value.replace('store://user.', ''); attributes[attr] = user ? await user[path] : ''; } } diff --git a/src/mixins/contextMixin.ts b/src/mixins/contextMixin.ts index 5a8e947a..d79d9a92 100644 --- a/src/mixins/contextMixin.ts +++ b/src/mixins/contextMixin.ts @@ -13,7 +13,7 @@ const ContextMixin = { return { ...base_context, ...this.extra_context }; }, get extra_context(): object { - let extraContextElement = this.extraContext + const extraContextElement = this.extraContext ? document.getElementById(this.extraContext) : // take element extra context first document.querySelector('[data-default-context]'); // ... or look for a default extra context diff --git a/src/mixins/counterMixin.ts b/src/mixins/counterMixin.ts index edb4cdac..21269aab 100644 --- a/src/mixins/counterMixin.ts +++ b/src/mixins/counterMixin.ts @@ -1,7 +1,7 @@ import { html } from 'lit'; import { unsafeHTML } from 'lit/directives/unsafe-html.js'; import { evalTemplateString } from '../libs/helpers'; -import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const CounterMixin = { name: 'counter-mixin', diff --git a/src/mixins/federationMixin.ts b/src/mixins/federationMixin.ts index 8a7df271..6dd269e5 100644 --- a/src/mixins/federationMixin.ts +++ b/src/mixins/federationMixin.ts @@ -1,4 +1,4 @@ -import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; import { store } from '../libs/store/store'; import type { Resource } from './interfaces'; diff --git a/src/mixins/filterMixin.ts b/src/mixins/filterMixin.ts index 9845903a..c4cb278d 100644 --- a/src/mixins/filterMixin.ts +++ b/src/mixins/filterMixin.ts @@ -1,7 +1,7 @@ import type { SearchQuery } from '../libs/interfaces'; import { searchInResources } from '../libs/filter'; import type { ServerSearchOptions } from '../libs/store/server-search'; -import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const FilterMixin = { name: 'filter-mixin', diff --git a/src/mixins/grouperMixin.ts b/src/mixins/grouperMixin.ts index 1e3d013d..efc3cb98 100644 --- a/src/mixins/grouperMixin.ts +++ b/src/mixins/grouperMixin.ts @@ -1,5 +1,5 @@ import { generalComparator } from '../libs/helpers'; -import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const GrouperMixin = { name: 'grouper-mixin', @@ -40,8 +40,8 @@ const GrouperMixin = { ) { const nextProcessor = listPostProcessors.shift(); if (this.groupBy) { - let groups = {}; - for (let resource of resources) { + const groups = {}; + for (const resource of resources) { const valueGroup = await resource[this.groupBy]; if (valueGroup == null) continue; if (!groups[valueGroup]) groups[valueGroup] = { resources: [] }; // if no group yet, we create one... @@ -61,7 +61,7 @@ const GrouperMixin = { group: g, parent: this.renderGroup(g, div), })); - for (let { group, parent } of parents) { + for (const { group, parent } of parents) { if (nextProcessor) await nextProcessor( groups[group].resources, // give only resources from group diff --git a/src/mixins/highlighterMixin.ts b/src/mixins/highlighterMixin.ts index 9fd2142e..96062d61 100644 --- a/src/mixins/highlighterMixin.ts +++ b/src/mixins/highlighterMixin.ts @@ -1,4 +1,4 @@ -import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const HighlighterMixin = { name: 'highlighter-mixin', @@ -15,7 +15,7 @@ const HighlighterMixin = { div: HTMLElement, context: string, ): Promise<void> { - for (let attr of this.element.attributes) { + for (const attr of this.element.attributes) { if (attr.name.startsWith('highlight-')) { const field = attr.name.split('highlight-')[1]; resources = await Promise.all( @@ -35,7 +35,7 @@ const HighlighterMixin = { }, sortHighlighted(resources, field, value) { - for (let [index, res] of resources.entries()) { + for (const [index, res] of resources.entries()) { if (res[field] && res[field] === value) { // put the current element at the beginning of the array resources.splice(0, 0, resources.splice(index, 1)[0]); // TODO : test with sort diff --git a/src/mixins/listMixin.ts b/src/mixins/listMixin.ts index 0501f9cf..79564f7d 100644 --- a/src/mixins/listMixin.ts +++ b/src/mixins/listMixin.ts @@ -124,7 +124,7 @@ const ListMixin = { context: string, ) { // Create child components - for (let resource of resources) { + for (const resource of resources) { if (!resource) continue; this.appendChildElt(resource['@id'], div); } diff --git a/src/mixins/paginateMixin.ts b/src/mixins/paginateMixin.ts index 64ba4254..b379e485 100644 --- a/src/mixins/paginateMixin.ts +++ b/src/mixins/paginateMixin.ts @@ -1,5 +1,5 @@ -import { html, TemplateResult } from 'lit'; -import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import { html, type TemplateResult } from 'lit'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const PaginateMixin = { name: 'paginate-mixin', diff --git a/src/mixins/requiredMixin.ts b/src/mixins/requiredMixin.ts index ba8737d8..dc4f79e5 100644 --- a/src/mixins/requiredMixin.ts +++ b/src/mixins/requiredMixin.ts @@ -1,4 +1,4 @@ -import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const RequiredMixin = { name: 'required-mixin', @@ -25,11 +25,11 @@ const RequiredMixin = { }); if (requiredFields.length) { - for (let resource of resources) { + for (const resource of resources) { let hasProps = true; - for (let field of requiredFields) { + for (const field of requiredFields) { // Retrieve resource from store - let res = await resource[field]; + const res = await resource[field]; if (!res) { hasProps = false; break; diff --git a/src/mixins/serverPaginationMixin.ts b/src/mixins/serverPaginationMixin.ts index 83aee402..20de7052 100644 --- a/src/mixins/serverPaginationMixin.ts +++ b/src/mixins/serverPaginationMixin.ts @@ -42,7 +42,7 @@ const ServerPaginationMixin = { }, async setCurrentOffset(resourceId: string, offset: number): Promise<void> { - let index = resourceId + '#p' + this.limit; + const index = resourceId + '#p' + this.limit; this.currentOffset[index] = this.offset = offset; this.pageNumber = Number(this.offset / this.limit); this.currentPage[resourceId] = this.pageNumber; @@ -51,7 +51,7 @@ const ServerPaginationMixin = { }, async decreaseCurrentOffset(resourceId: string): Promise<void> { - let index = resourceId + '#p' + this.limit; + const index = resourceId + '#p' + this.limit; this.currentOffset[index] = this.offset = this.offset - this.limit; this.currentPage[index] = this.offset / this.limit; this.pageNumber = this.offset / this.limit; @@ -61,7 +61,7 @@ const ServerPaginationMixin = { }, async increaseCurrentOffset(resourceId: string): Promise<void> { - let index = resourceId + '#p' + this.limit; + const index = resourceId + '#p' + this.limit; this.currentOffset[index] = this.offset = this.offset + this.limit; this.currentPage[index] = this.offset / this.limit; diff --git a/src/mixins/sorterMixin.ts b/src/mixins/sorterMixin.ts index 47d6c832..2f88089f 100644 --- a/src/mixins/sorterMixin.ts +++ b/src/mixins/sorterMixin.ts @@ -1,4 +1,4 @@ -import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const SorterMixin = { name: 'sorter-mixin', diff --git a/src/mixins/storeMixin.ts b/src/mixins/storeMixin.ts index a28419a4..ea1d45c8 100644 --- a/src/mixins/storeMixin.ts +++ b/src/mixins/storeMixin.ts @@ -71,7 +71,7 @@ const StoreMixin = { if (this.subscription) PubSub.unsubscribe(this.subscription); }, get resource(): Resource | null { - let id = this.resourceId; + const id = this.resourceId; const serverPagination = formatAttributesToServerPaginationOptions( this.element.attributes, ); diff --git a/src/mixins/widgetMixin.ts b/src/mixins/widgetMixin.ts index f8de0f6a..56b187e5 100644 --- a/src/mixins/widgetMixin.ts +++ b/src/mixins/widgetMixin.ts @@ -4,8 +4,8 @@ import { findClosingBracketMatchIndex, } from '../libs/helpers'; import { newWidgetFactory } from '../new-widgets/new-widget-factory'; -import { WidgetInterface, WidgetType, Resource } from './interfaces'; -import { html, render, TemplateResult } from 'lit'; +import { type WidgetInterface, WidgetType, type Resource } from './interfaces'; +import { html, render, type TemplateResult } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; const WidgetMixin = { @@ -57,13 +57,13 @@ const WidgetMixin = { let resource = this.resource as Resource; if (resource && resource.isContainer?.()) { // If container, keep the 1rst resource - for (let res of resource['ldp:contains']) { + for (const res of resource['ldp:contains']) { resource = res; break; } } else if (resource && this.arrayField && this.predicateName) { // if array, keep the 1rst resource - for (let res of resource[this.predicateName]) { + for (const res of resource[this.predicateName]) { resource = res; break; } @@ -73,7 +73,7 @@ const WidgetMixin = { console.error(new Error('You must provide a "fields" attribute')); if (!resource) return []; - let fields: string[] = []; + const fields: string[] = []; for (const prop of resource.properties) { if (!prop.startsWith('@') && !(prop === 'permissions')) { if (!this.isAlias(prop) && (await resource[prop])) fields.push(prop); @@ -126,7 +126,7 @@ const WidgetMixin = { */ isSet(field: string): boolean { if (!this.fields) return false; - let foundSets = this.fields.match(this.getSetRegexp(field)); + const foundSets = this.fields.match(this.getSetRegexp(field)); return foundSets ? foundSets.length > 0 : false; }, /** @@ -157,7 +157,7 @@ const WidgetMixin = { fieldValue === undefined || fieldValue === '' ) { - let expandedPredicate = sibStore.getExpandedPredicate( + const expandedPredicate = sibStore.getExpandedPredicate( field, this.context, ); @@ -200,7 +200,7 @@ const WidgetMixin = { return await this.fetchValue(alias[0], resource); } - let resourceValue = await this.fetchValue(field, resource); + const resourceValue = await this.fetchValue(field, resource); // Empty value if ( resourceValue === undefined || @@ -236,7 +236,7 @@ const WidgetMixin = { * @param field - string * @param isSet - boolean */ - getWidget(field: string, isSet: boolean = false): WidgetInterface { + getWidget(field: string, isSet = false): WidgetInterface { if (this.isAlias(field)) field = field.split(' as ')[1]; const widget = this.element.getAttribute('widget-' + field); @@ -291,7 +291,7 @@ const WidgetMixin = { 'add-class', 'remove-class', ]; - for (let attr of multipleAttributes) + for (const attr of multipleAttributes) this.addToAttributes(`multiple-${escapedField}-${attr}`, attr, attrs); // transfer all [attr]-[field] attributes as [attr] attribute for widget [field] @@ -328,13 +328,13 @@ const WidgetMixin = { 'target-src', 'data-label', ]; - for (let attr of defaultAttributes) + for (const attr of defaultAttributes) this.addToAttributes(`${attr}-${escapedField}`, attr, attrs); const addableAttributes: Attr[] = ( Array.from(this.element.attributes) as Attr[] ).filter((a: Attr) => a.name.startsWith(`addable-${escapedField}`)); - for (let attr of addableAttributes) + for (const attr of addableAttributes) this.addToAttributes( attr.name, attr.name.replace(`addable-${escapedField}`, 'addable'), @@ -372,7 +372,7 @@ const WidgetMixin = { let widgetTemplate: TemplateResult = html``; // Set attributes - let value = await this.getValue(field, currentResource); + const value = await this.getValue(field, currentResource); if (widgetMeta.type === WidgetType.NATIVE) { // native widget (ie: h1) widgetTemplate = preHTML`<${tagName} name="${ifDefined(attributes.name)}" class="${ifDefined(attributes.class)}">${value}</${tagName}>`; @@ -394,7 +394,7 @@ const WidgetMixin = { attributes['data-src'] = value['@id']; } else { try { - let isUrl = new URL(value); + const isUrl = new URL(value); if (isUrl) attributes['data-src'] = value; } catch (e) {} @@ -438,7 +438,7 @@ const WidgetMixin = { // Get set attributes const attrs = { name: field }; const setAttributes = ['class', 'label']; - for (let attr of setAttributes) + for (const attr of setAttributes) this.addToAttributes(`${attr}-${field}`, attr, attrs); // Create widget if not already existing @@ -450,11 +450,11 @@ const WidgetMixin = { widget = document.createElement(setWidget.tagName); initializing = true; } - for (let name of Object.keys(attrs)) { + for (const name of Object.keys(attrs)) { this.defineAttribute(widget, name, attrs[name], setWidget.type); } if (widget.component && initializing) widget.component.render(); - let setFields = this.getSet(field); + const setFields = this.getSet(field); // Catch widget for the set if all these fields are empty if (this.element.hasAttribute('empty-' + field)) { let hasOnlyEmpty = true; diff --git a/src/new-widgets/callbackMixins/autocompletionMixin.ts b/src/new-widgets/callbackMixins/autocompletionMixin.ts index b7a7a7fc..5945ac1f 100644 --- a/src/new-widgets/callbackMixins/autocompletionMixin.ts +++ b/src/new-widgets/callbackMixins/autocompletionMixin.ts @@ -5,7 +5,7 @@ import { } from '../../libs/helpers'; import SlimSelect from 'slim-select'; import { TranslationMixin } from '../../mixins/translationMixin'; -import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const AutocompletionMixin = { name: 'autocompletion-mixin', diff --git a/src/new-widgets/callbackMixins/richtextMixin.ts b/src/new-widgets/callbackMixins/richtextMixin.ts index db754528..f87cf2df 100644 --- a/src/new-widgets/callbackMixins/richtextMixin.ts +++ b/src/new-widgets/callbackMixins/richtextMixin.ts @@ -2,7 +2,7 @@ import Quill from 'quill'; import deltaMd from 'delta-markdown-for-quill'; import { importInlineCSS } from '../../libs/helpers.js'; -import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.js'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.js'; const RichtextMixin = { name: 'richtext-mixin', @@ -118,7 +118,7 @@ const RichtextMixin = { removeErrorMessageAndStyling() { // Remove any previously displayed error message and error styling const richtext = this.element.querySelector('[data-richtext]'); - let errorMessageElement = richtext.querySelector( + const errorMessageElement = richtext.querySelector( '.required-error-message', ) as HTMLDivElement; if (errorMessageElement) errorMessageElement.remove(); diff --git a/src/new-widgets/templateAdditionMixins/addableMixin.ts b/src/new-widgets/templateAdditionMixins/addableMixin.ts index 81384e5c..6045249e 100644 --- a/src/new-widgets/templateAdditionMixins/addableMixin.ts +++ b/src/new-widgets/templateAdditionMixins/addableMixin.ts @@ -1,4 +1,4 @@ -import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; import { spread } from '../../libs/lit-helpers'; import { html } from 'lit'; @@ -16,7 +16,7 @@ const AddableMixin = { (a: Attr) => a.name.startsWith('addable-'), ); const cleanAddableAttr: { [key: string]: string } = {}; - for (let attr of addableAttr) + for (const attr of addableAttr) cleanAddableAttr[attr.name.replace('addable-', '')] = attr.value; if (!Object.hasOwn(cleanAddableAttr, 'data-src')) cleanAddableAttr['data-src'] = this.range; diff --git a/src/new-widgets/templateAdditionMixins/labelLastMixin.ts b/src/new-widgets/templateAdditionMixins/labelLastMixin.ts index f454db39..b9a87223 100644 --- a/src/new-widgets/templateAdditionMixins/labelLastMixin.ts +++ b/src/new-widgets/templateAdditionMixins/labelLastMixin.ts @@ -1,5 +1,5 @@ import { html } from 'lit'; -import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const LabelLastMixin = { name: 'label-last-mixin', diff --git a/src/new-widgets/templateAdditionMixins/labelMixin.ts b/src/new-widgets/templateAdditionMixins/labelMixin.ts index e725e08a..338dfd5e 100644 --- a/src/new-widgets/templateAdditionMixins/labelMixin.ts +++ b/src/new-widgets/templateAdditionMixins/labelMixin.ts @@ -1,6 +1,6 @@ import { html } from 'lit'; import { uniqID } from '../../libs/helpers'; -import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const LabelMixin = { name: 'label-mixin', diff --git a/src/new-widgets/templatesDependencies/editableMixin.ts b/src/new-widgets/templatesDependencies/editableMixin.ts index 77107114..fa59c7a7 100644 --- a/src/new-widgets/templatesDependencies/editableMixin.ts +++ b/src/new-widgets/templatesDependencies/editableMixin.ts @@ -2,7 +2,7 @@ import { StoreMixin } from '../../mixins/storeMixin'; import { store } from '../../libs/store/store'; import { html } from 'lit'; -import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const EditableMixin = { name: 'editable-mixin', diff --git a/src/new-widgets/templatesDependencies/multipleFormMixin.ts b/src/new-widgets/templatesDependencies/multipleFormMixin.ts index 8f301cd3..fb0a20f6 100644 --- a/src/new-widgets/templatesDependencies/multipleFormMixin.ts +++ b/src/new-widgets/templatesDependencies/multipleFormMixin.ts @@ -1,4 +1,4 @@ -import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; import { StoreMixin } from '../../mixins/storeMixin'; const MultipleFormMixin = { @@ -93,13 +93,13 @@ const MultipleFormMixin = { this.listAttributes['children'] = []; // reset list // set value in form - for (let resource of this.resource['ldp:contains']) { + for (const resource of this.resource['ldp:contains']) { // for each resource this.insertWidget(resource['@id']); // create a widget } this.planRender(); }, - insertWidget(value: string = '') { + insertWidget(value = '') { if (!this.widget) return; const widget = document.createElement(this.widget); const attributes = { @@ -108,7 +108,7 @@ const MultipleFormMixin = { value: value, range: this.range, }; - for (let name of Object.keys(attributes)) { + for (const name of Object.keys(attributes)) { if (typeof attributes[name] === 'boolean') widget.toggleAttribute(name, attributes[name]); else widget.setAttribute(name, attributes[name]); @@ -124,7 +124,7 @@ const MultipleFormMixin = { // Was returning an array of functions, now returns an array of values. // Not sure about the tests results in that context return Array.from(this.dataHolder).map((element: any) => { - let elValue = this.getValueFromElement(element); + const elValue = this.getValueFromElement(element); return elValue; }); }, diff --git a/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts b/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts index 154a6c6d..e0505c0d 100644 --- a/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts +++ b/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts @@ -1,4 +1,4 @@ -import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; import { StoreMixin } from '../../mixins/storeMixin'; const MultipleselectFormMixin = { @@ -47,7 +47,7 @@ const MultipleselectFormMixin = { setDataSrc(value: string, listValueTransformations: PostProcessorRegistry) { if (value && value !== this.dataSrc) { try { - let values = JSON.parse(value); + const values = JSON.parse(value); if (values && Array.isArray(values)) { this.setValue(values); } else { diff --git a/src/new-widgets/templatesDependencies/rangeMixin.ts b/src/new-widgets/templatesDependencies/rangeMixin.ts index fc980071..d3e0a6c3 100644 --- a/src/new-widgets/templatesDependencies/rangeMixin.ts +++ b/src/new-widgets/templatesDependencies/rangeMixin.ts @@ -95,7 +95,7 @@ const RangeMixin = { selectedValue; // literal //TODO: this splitting and expanding is disgusting, please find another solution !! - let labelProperty = this.optionLabel.split(/[.]+/).pop(); + const labelProperty = this.optionLabel.split(/[.]+/).pop(); const label = await res[labelProperty]; // label of the option return { value, label, selectedValue }; }; diff --git a/src/new-widgets/valueTransformationMixins/autolinkMixin.ts b/src/new-widgets/valueTransformationMixins/autolinkMixin.ts index 351aead1..58d52a9c 100644 --- a/src/new-widgets/valueTransformationMixins/autolinkMixin.ts +++ b/src/new-widgets/valueTransformationMixins/autolinkMixin.ts @@ -1,5 +1,5 @@ import { Autolinker } from 'autolinker'; -import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const AutolinkMixin = { name: 'autolink-mixin', diff --git a/src/new-widgets/valueTransformationMixins/dateMixin.ts b/src/new-widgets/valueTransformationMixins/dateMixin.ts index 8c87824c..ce9b9118 100644 --- a/src/new-widgets/valueTransformationMixins/dateMixin.ts +++ b/src/new-widgets/valueTransformationMixins/dateMixin.ts @@ -1,4 +1,4 @@ -import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const DateMixin = { name: 'date-mixin', @@ -25,11 +25,11 @@ const DateMixin = { if (nextProcessor) nextProcessor(newValue, listValueTransformations); }, formatDateForInput(date: string) { - let d = new Date(date); + const d = new Date(date); if (Number.isNaN(d.getTime())) throw new Error('Invalid date'); let month = `${d.getMonth() + 1}`; let day = `${d.getDate()}`; - let year = d.getFullYear(); + const year = d.getFullYear(); if (month.length < 2) month = `0${month}`; if (day.length < 2) day = `0${day}`; diff --git a/src/new-widgets/valueTransformationMixins/dateTimeMixin.ts b/src/new-widgets/valueTransformationMixins/dateTimeMixin.ts index 68e28202..c18f59f5 100644 --- a/src/new-widgets/valueTransformationMixins/dateTimeMixin.ts +++ b/src/new-widgets/valueTransformationMixins/dateTimeMixin.ts @@ -1,4 +1,4 @@ -import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const DateTimeMixin = { name: 'date-time-mixin', diff --git a/src/new-widgets/valueTransformationMixins/markdownMixin.ts b/src/new-widgets/valueTransformationMixins/markdownMixin.ts index 1d369565..3e9a0478 100644 --- a/src/new-widgets/valueTransformationMixins/markdownMixin.ts +++ b/src/new-widgets/valueTransformationMixins/markdownMixin.ts @@ -2,7 +2,7 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js'; import markdownit from 'markdown-it'; import mila from 'markdown-it-link-attributes'; -import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const MarkdownMixin = { name: 'markdown-mixin', diff --git a/src/new-widgets/valueTransformationMixins/multilineMixin.ts b/src/new-widgets/valueTransformationMixins/multilineMixin.ts index 2072f114..3cddca3d 100644 --- a/src/new-widgets/valueTransformationMixins/multilineMixin.ts +++ b/src/new-widgets/valueTransformationMixins/multilineMixin.ts @@ -1,5 +1,5 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js'; -import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const MultilineMixin = { name: 'multiline-mixin', diff --git a/src/new-widgets/valueTransformationMixins/oembedMixin.ts b/src/new-widgets/valueTransformationMixins/oembedMixin.ts index eb44fb7d..c16680c6 100644 --- a/src/new-widgets/valueTransformationMixins/oembedMixin.ts +++ b/src/new-widgets/valueTransformationMixins/oembedMixin.ts @@ -1,5 +1,5 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js'; -import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const OembedMixin = { name: 'oembed-mixin', diff --git a/src/solid-template-element.ts b/src/solid-template-element.ts index b4facf2b..16b86cf6 100644 --- a/src/solid-template-element.ts +++ b/src/solid-template-element.ts @@ -20,7 +20,7 @@ export default class SolidTemplateElement extends HTMLElement { initProps() { this.props = {}; - for (let key in this.constructor.propsDefinition) { + for (const key in this.constructor.propsDefinition) { this.props[key] = undefined; } } @@ -29,7 +29,7 @@ export default class SolidTemplateElement extends HTMLElement { const declaredAttributes: string[] = []; // Get props values - for (let key in this.constructor.propsDefinition) { + for (const key in this.constructor.propsDefinition) { const def = this.constructor.propsDefinition[key]; if (typeof def === 'string') { this.props[key] = this.hasAttribute(def) @@ -49,7 +49,7 @@ export default class SolidTemplateElement extends HTMLElement { } // Add attributes to props - for (let attr of this.attributes) { + for (const attr of this.attributes) { if (!declaredAttributes.includes(attr.name)) { // if attribute not in propsDefinition this.props[this._camelize(attr.name)] = attr.value || undefined; // add it to props diff --git a/src/widgets/baseWidget.ts b/src/widgets/baseWidget.ts index c5244107..87d2020a 100644 --- a/src/widgets/baseWidget.ts +++ b/src/widgets/baseWidget.ts @@ -63,7 +63,7 @@ export class BaseWidget extends HTMLElement { } get value() { if (this.dataHolder) { - let values = this.dataHolder.map(element => { + const values = this.dataHolder.map(element => { if (element instanceof HTMLInputElement && element.type === 'checkbox') return element.checked; // if value is defined, push it in the array @@ -165,7 +165,7 @@ export class BaseWidget extends HTMLElement { } async fetchSources(resource: any) { if (!resource || !resource['ldp:contains']) return null; - let resources: any[] = []; + const resources: any[] = []; let index = 0; for (let res of resource['ldp:contains']) { if (!res) { @@ -179,7 +179,7 @@ export class BaseWidget extends HTMLElement { } if (res.isContainer?.()) { // if nested container - let resourcesFromContainer = await store.getData( + const resourcesFromContainer = await store.getData( res['@id'], this.context, ); // fetch the datas @@ -211,7 +211,7 @@ export class BaseWidget extends HTMLElement { ) { // selected options for multiple select selected = false; - for await (let value of this._value['ldp:contains']) { + for await (const value of this._value['ldp:contains']) { if (value['@id'] === element['@id']) { selected = true; break; diff --git a/src/widgets/widget-factory.ts b/src/widgets/widget-factory.ts index 01e4acc9..f2fd5d20 100644 --- a/src/widgets/widget-factory.ts +++ b/src/widgets/widget-factory.ts @@ -4,7 +4,7 @@ import { defineComponent } from '../libs/helpers'; export const widgetFactory = ( tagName: string, customTemplate: string, - childTemplate: string = '', + childTemplate = '', callback?: (element: Element) => void, ) => { const registered = customElements.get(tagName); -- GitLab From 93b66a66cd4ad5855bf04a747e02c02e6d177182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Tue, 19 Nov 2024 03:15:39 +0100 Subject: [PATCH 38/66] fix `lint/style` errors (partial) --- biome.jsonc | 6 ++++++ cypress/e2e/e2e/reactivity-e2e.cy.ts | 8 ++++---- server.js | 8 ++++---- src/libs/helpers.ts | 10 ++++------ src/libs/store/store.ts | 3 +-- src/logger.ts | 2 +- src/mixins/filterMixin.ts | 2 +- src/mixins/validationMixin.ts | 4 ++-- src/solid.d.ts | 2 +- src/store.d.ts | 2 +- src/window.d.ts | 20 +++++++++++--------- vite.config.ts | 2 +- 12 files changed, 37 insertions(+), 32 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index 184a3aa7..8c6e2ce2 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -19,6 +19,12 @@ "enabled": true, "rules": { "recommended": true, + "style": { + "noUselessElse": "off", + "noParameterAssign": "off", + "noNonNullAssertion": "off", + "useTemplate": "off" + }, "complexity": { "useLiteralKeys": "off", "noForEach": "off", diff --git a/cypress/e2e/e2e/reactivity-e2e.cy.ts b/cypress/e2e/e2e/reactivity-e2e.cy.ts index ed42d024..b676d48d 100644 --- a/cypress/e2e/e2e/reactivity-e2e.cy.ts +++ b/cypress/e2e/e2e/reactivity-e2e.cy.ts @@ -248,7 +248,7 @@ describe('Reactivity e2e test2', { testIsolation: false }, function () { // List solid-display & range const newSrc = 'https://ldp-server.test/users/alex/'; - cy.get(`solid-display#users solid-display`).should('have.length', 3); + cy.get('solid-display#users solid-display').should('have.length', 3); cy.get( `solid-display#users solid-display[data-src="${newSrc}"] > div > solid-display-value[name="first_name"]`, ).should('contain', 'Alex'); @@ -258,7 +258,7 @@ describe('Reactivity e2e test2', { testIsolation: false }, function () { cy.get( `solid-display#users solid-display[data-src="${newSrc}"] > div > solid-display-value[name="username"]`, ).should('contain', 'alex'); - cy.get(`solid-form#range option`).should('have.length', 4); + cy.get('solid-form#range option').should('have.length', 4); // Federation cy.get( @@ -276,8 +276,8 @@ describe('Reactivity e2e test2', { testIsolation: false }, function () { fixture: 'users-paris.jsonld', }); cy.get('solid-delete#delete-user > button').click(); - cy.get(`solid-display#users solid-display`).should('have.length', 2); - cy.get(`solid-form#range option`).should('have.length', 3); + cy.get('solid-display#users solid-display').should('have.length', 2); + cy.get('solid-form#range option').should('have.length', 3); // cy.get(`solid-display#federation solid-display`).should('have.length', 3); NOT WORKING: should we loop on subscription index? }); diff --git a/server.js b/server.js index 54e0fc04..799c155e 100644 --- a/server.js +++ b/server.js @@ -1,12 +1,12 @@ // @ts-check -import crypto from 'crypto'; +import crypto from 'node:crypto'; import cypress from 'cypress'; -import url from 'url'; -import path from 'path'; +import url from 'node:url'; +import path from 'node:path'; import express from 'express'; import findFreePort from 'find-free-port'; -import fs from 'fs/promises'; +import fs from 'node:fs/promises'; import cors from 'cors'; const port = findFreePort(3000); const app = express(); diff --git a/src/libs/helpers.ts b/src/libs/helpers.ts index 65a61f3f..b7337e89 100644 --- a/src/libs/helpers.ts +++ b/src/libs/helpers.ts @@ -1,7 +1,7 @@ import Fuse from 'fuse.js'; function uniqID(): string { - return '_' + (Math.random() * Math.pow(36, 20)).toString(36).slice(0, 10); + return '_' + (Math.random() * 36 ** 20).toString(36).slice(0, 10); } function stringToDom(html: string): DocumentFragment { @@ -106,8 +106,8 @@ function relativeSource(source: string) { function loadScript(source: string) { source = relativeSource(source); return new Promise(resolve => { - var script = document.createElement('script'); - var head = document.querySelector('head'); + const script = document.createElement('script'); + const head = document.querySelector('head'); script.async = true; script.onload = () => setTimeout(resolve, 0); script.src = source; @@ -140,8 +140,6 @@ function setDeepProperty( function parseFieldsString(fields: string): string[] { if (!fields) return []; - let fieldsArray: string[]; - // remove all sets from fields while (fields.indexOf('(') > 0) { const firstBracket = fields.indexOf('('); @@ -153,7 +151,7 @@ function parseFieldsString(fields: string): string[] { } const re = /((^\s*|,)\s*)(("(\\"|[^"])*")|('(\\'|[^'])*')|[^,]*)/gm; // match , not inside quotes - fieldsArray = fields.match(re) || []; // separate fields + const fieldsArray = fields.match(re) || []; // separate fields if (!fieldsArray) return []; return fieldsArray.map(a => a.replace(/^[\s,]+/, '')); // remove commas and spaces } diff --git a/src/libs/store/store.ts b/src/libs/store/store.ts index a033aa7e..512723f7 100644 --- a/src/libs/store/store.ts +++ b/src/libs/store/store.ts @@ -1,6 +1,5 @@ import JSONLDContextParser from 'jsonld-context-parser'; -//@ts-ignore -import PubSub from 'https://cdn.skypack.dev/pubsub-js'; +import PubSub from 'pubsub-js'; import jsonld from 'jsonld'; import { CustomGetter } from './custom-getter'; diff --git a/src/logger.ts b/src/logger.ts index b80e40cc..7925f16b 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -30,7 +30,7 @@ function formatMessage(level, messages) { return `${color}[${timestamp}] ${formattedMessages}${colors.reset}`; } -var originalFactory = log.methodFactory; +const originalFactory = log.methodFactory; log.methodFactory = (methodName, logLevel, loggerName) => { const rawMethod = originalFactory(methodName, logLevel, loggerName); diff --git a/src/mixins/filterMixin.ts b/src/mixins/filterMixin.ts index c4cb278d..2098ef0e 100644 --- a/src/mixins/filterMixin.ts +++ b/src/mixins/filterMixin.ts @@ -159,7 +159,7 @@ const FilterMixin = { this.searchForm = document.getElementById(filteredBy); if (!this.searchForm) throw `#${filteredBy} is not in DOM`; } else { - this.searchForm = document.createElement(`solid-form-search`); + this.searchForm = document.createElement('solid-form-search'); } this.searchForm.component.attach(this); this.searchForm.addEventListener('formChange', () => { diff --git a/src/mixins/validationMixin.ts b/src/mixins/validationMixin.ts index 138db14b..d2b55238 100644 --- a/src/mixins/validationMixin.ts +++ b/src/mixins/validationMixin.ts @@ -42,7 +42,7 @@ const ValidationMixin = { this.dialogID = uniqID(); }, showModal() { - var dialog: any = document.getElementById(this.dialogID); + const dialog: any = document.getElementById(this.dialogID); dialogPolyfill.registerDialog(dialog); return dialog.showModal(); }, @@ -68,7 +68,7 @@ const ValidationMixin = { getModalDialog() { if (this.confirmationType === 'dialog') { const quitDialog = () => { - var dialog: any = document.getElementById(this.dialogID); + const dialog: any = document.getElementById(this.dialogID); if (dialog == null) return; dialog.close(); }; diff --git a/src/solid.d.ts b/src/solid.d.ts index 78626222..05f3a28a 100644 --- a/src/solid.d.ts +++ b/src/solid.d.ts @@ -1 +1 @@ -declare var solid: any; +declare let solid: any; diff --git a/src/store.d.ts b/src/store.d.ts index 72f0fdcb..a3a92d73 100644 --- a/src/store.d.ts +++ b/src/store.d.ts @@ -1,4 +1,4 @@ -declare var sibStore: any; +declare let sibStore: any; interface StoreOptions { fetchMethod?: Promise<any>; diff --git a/src/window.d.ts b/src/window.d.ts index 783e1ea9..3f370e97 100644 --- a/src/window.d.ts +++ b/src/window.d.ts @@ -1,9 +1,11 @@ -declare var PubSub: any; -declare var markdownit: any; -declare var fetchTranslationPromise: Promise; -declare var cachePropsSearchFilter: { - [key: string]: { - setFields: string[] | null; - setSearchFields: string[] | null; - }; -}; +export declare global { + interface Window { + fetchTranslationPromise: Promise; + cachePropsSearchFilter: { + [key: string]: { + setFields: string[] | null; + setSearchFields: string[] | null; + }; + }; + } +} diff --git a/vite.config.ts b/vite.config.ts index e7f799de..d6bb5745 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,4 +1,4 @@ -import { resolve } from 'path'; +import { resolve } from 'node:path'; import { defineConfig } from 'vite'; export default defineConfig({ -- GitLab From f224fb006456c050f41246ad9445de51acb6a4fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Tue, 19 Nov 2024 15:23:39 +0100 Subject: [PATCH 39/66] fix `organizeImports` biome errors --- biome.jsonc | 2 +- cypress/e2e/unit/helpers.cy.ts | 12 ++++----- server.js | 8 +++--- src/components/solid-ac-checker.ts | 2 +- src/components/solid-delete.ts | 4 +-- src/components/solid-display.ts | 16 ++++++------ src/components/solid-form-search.ts | 4 +-- src/components/solid-form.ts | 10 +++---- src/components/solid-member-add.ts | 4 +-- src/components/solid-member-delete.ts | 4 +-- src/components/solid-membership.ts | 2 +- src/components/solid-table.ts | 18 ++++++------- src/components/solid-widget.ts | 8 +++--- src/index.ts | 26 +++++++++---------- src/libs/ComponentFactory.ts | 8 +++--- src/libs/Compositor.ts | 8 +++--- src/libs/filter.ts | 4 +-- src/libs/lit-helpers.ts | 12 ++++----- src/libs/store/custom-getter.ts | 2 +- src/mixins/counterMixin.ts | 2 +- src/mixins/filterMixin.ts | 4 +-- src/mixins/grouperMixin.ts | 2 +- src/mixins/listMixin.ts | 2 +- src/mixins/paginateMixin.ts | 2 +- src/mixins/storeMixin.ts | 6 ++--- src/mixins/validationMixin.ts | 2 +- src/mixins/widgetMixin.ts | 10 +++---- src/new-widgets/attributeMixins/index.ts | 8 +++--- .../callbackMixins/autocompletionMixin.ts | 4 +-- .../callbackMixins/richtextMixin.ts | 2 +- src/new-widgets/new-widget-factory.ts | 10 +++---- .../templateAdditionMixins/index.ts | 4 +-- .../templateAdditionMixins/labelMixin.ts | 2 +- .../templates/displayTemplatesDirectory.ts | 2 +- .../templates/formTemplatesDirectory.ts | 16 ++++++------ src/new-widgets/templates/index.ts | 2 +- .../templatesDependencies/editableMixin.ts | 2 +- .../templatesDependencies/index.ts | 2 +- .../templatesDependencies/rangeMixin.ts | 6 ++--- .../valueTransformationMixins/index.ts | 4 +-- src/widgets/widget-factory.ts | 2 +- 41 files changed, 125 insertions(+), 125 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index 8c6e2ce2..5cb4acea 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -13,7 +13,7 @@ "indentStyle": "space" }, "organizeImports": { - "enabled": false + "enabled": true }, "linter": { "enabled": true, diff --git a/cypress/e2e/unit/helpers.cy.ts b/cypress/e2e/unit/helpers.cy.ts index a616652f..b8ad05c3 100644 --- a/cypress/e2e/unit/helpers.cy.ts +++ b/cypress/e2e/unit/helpers.cy.ts @@ -1,11 +1,11 @@ import { - uniqID, - stringToDom, - setDeepProperty, - parseFieldsString, - findClosingBracketMatchIndex, - evalTemplateString, AsyncIterableBuilder, + evalTemplateString, + findClosingBracketMatchIndex, + parseFieldsString, + setDeepProperty, + stringToDom, + uniqID, } from '../../../src/libs/helpers'; /** diff --git a/server.js b/server.js index 799c155e..239e1afa 100644 --- a/server.js +++ b/server.js @@ -1,13 +1,13 @@ // @ts-check import crypto from 'node:crypto'; -import cypress from 'cypress'; -import url from 'node:url'; +import fs from 'node:fs/promises'; import path from 'node:path'; +import url from 'node:url'; +import cors from 'cors'; +import cypress from 'cypress'; import express from 'express'; import findFreePort from 'find-free-port'; -import fs from 'node:fs/promises'; -import cors from 'cors'; const port = findFreePort(3000); const app = express(); const distPath = '.'; diff --git a/src/components/solid-ac-checker.ts b/src/components/solid-ac-checker.ts index 3fec2c6f..e408c022 100644 --- a/src/components/solid-ac-checker.ts +++ b/src/components/solid-ac-checker.ts @@ -1,7 +1,7 @@ import JSONLDContextParser from 'jsonld-context-parser'; import { Sib } from '../libs/Sib'; -import { StoreMixin } from '../mixins/storeMixin'; import { trackRenderAsync } from '../logger'; +import { StoreMixin } from '../mixins/storeMixin'; export const SolidAcChecker = { name: 'solid-ac-checker', diff --git a/src/components/solid-delete.ts b/src/components/solid-delete.ts index 483175f0..e47f4bda 100644 --- a/src/components/solid-delete.ts +++ b/src/components/solid-delete.ts @@ -1,12 +1,12 @@ import { Sib } from '../libs/Sib'; import { store } from '../libs/store/store'; +import { AttributeBinderMixin } from '../mixins/attributeBinderMixin'; import { NextMixin } from '../mixins/nextMixin'; import { ValidationMixin } from '../mixins/validationMixin'; -import { AttributeBinderMixin } from '../mixins/attributeBinderMixin'; import { html, render } from 'lit'; -import { ContextMixin } from '../mixins/contextMixin'; import { trackRenderAsync } from '../logger'; +import { ContextMixin } from '../mixins/contextMixin'; export const SolidDelete = { name: 'solid-delete', diff --git a/src/components/solid-display.ts b/src/components/solid-display.ts index ddf5ea60..f32959c6 100644 --- a/src/components/solid-display.ts +++ b/src/components/solid-display.ts @@ -1,17 +1,17 @@ import { Sib } from '../libs/Sib'; -import { WidgetMixin } from '../mixins/widgetMixin'; -import { ListMixin } from '../mixins/listMixin'; -import { StoreMixin } from '../mixins/storeMixin'; -import { PaginateMixin } from '../mixins/paginateMixin'; -import { FilterMixin } from '../mixins/filterMixin'; +import { spread } from '../libs/lit-helpers'; import { CounterMixin } from '../mixins/counterMixin'; -import { SorterMixin } from '../mixins/sorterMixin'; -import { GrouperMixin } from '../mixins/grouperMixin'; import { FederationMixin } from '../mixins/federationMixin'; +import { FilterMixin } from '../mixins/filterMixin'; +import { GrouperMixin } from '../mixins/grouperMixin'; import { HighlighterMixin } from '../mixins/highlighterMixin'; +import { ListMixin } from '../mixins/listMixin'; import { NextMixin } from '../mixins/nextMixin'; +import { PaginateMixin } from '../mixins/paginateMixin'; import { RequiredMixin } from '../mixins/requiredMixin'; -import { spread } from '../libs/lit-helpers'; +import { SorterMixin } from '../mixins/sorterMixin'; +import { StoreMixin } from '../mixins/storeMixin'; +import { WidgetMixin } from '../mixins/widgetMixin'; import { html, render } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; diff --git a/src/components/solid-form-search.ts b/src/components/solid-form-search.ts index 340d4148..0045f216 100644 --- a/src/components/solid-form-search.ts +++ b/src/components/solid-form-search.ts @@ -1,14 +1,14 @@ import { Sib } from '../libs/Sib'; -import { WidgetMixin } from '../mixins/widgetMixin'; import { AttributeBinderMixin } from '../mixins/attributeBinderMixin'; import { ContextMixin } from '../mixins/contextMixin'; import type { WidgetInterface } from '../mixins/interfaces'; +import { WidgetMixin } from '../mixins/widgetMixin'; import { newWidgetFactory } from '../new-widgets/new-widget-factory'; import { html, render } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; import { uniqID } from '../libs/helpers'; -import type { SearchQuery, FilterEventOptions } from '../libs/interfaces'; +import type { FilterEventOptions, SearchQuery } from '../libs/interfaces'; import { trackRenderAsync } from '../logger'; export const SolidFormSearch = { diff --git a/src/components/solid-form.ts b/src/components/solid-form.ts index 60d69cb8..285c3711 100644 --- a/src/components/solid-form.ts +++ b/src/components/solid-form.ts @@ -1,11 +1,11 @@ import { Sib } from '../libs/Sib'; -import { WidgetMixin } from '../mixins/widgetMixin'; -import { StoreMixin } from '../mixins/storeMixin'; -import { NextMixin } from '../mixins/nextMixin'; -import { ValidationMixin } from '../mixins/validationMixin'; -import { store } from '../libs/store/store'; import { setDeepProperty, transformArrayToContainer } from '../libs/helpers'; +import { store } from '../libs/store/store'; import type { WidgetInterface } from '../mixins/interfaces'; +import { NextMixin } from '../mixins/nextMixin'; +import { StoreMixin } from '../mixins/storeMixin'; +import { ValidationMixin } from '../mixins/validationMixin'; +import { WidgetMixin } from '../mixins/widgetMixin'; import { html, render } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; diff --git a/src/components/solid-member-add.ts b/src/components/solid-member-add.ts index 03285bb4..7d4e2946 100644 --- a/src/components/solid-member-add.ts +++ b/src/components/solid-member-add.ts @@ -4,10 +4,10 @@ import { NextMixin } from '../mixins/nextMixin'; import { ValidationMixin } from '../mixins/validationMixin'; import { html, render } from 'lit'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { ContextMixin } from '../mixins/contextMixin'; -import { newWidgetFactory } from '../new-widgets/new-widget-factory'; import { StoreMixin } from '../mixins/storeMixin'; -import { ifDefined } from 'lit/directives/if-defined.js'; +import { newWidgetFactory } from '../new-widgets/new-widget-factory'; export const SolidMemberAdd = { name: 'solid-member-add', diff --git a/src/components/solid-member-delete.ts b/src/components/solid-member-delete.ts index 935ddcef..010e011d 100644 --- a/src/components/solid-member-delete.ts +++ b/src/components/solid-member-delete.ts @@ -1,12 +1,12 @@ +import { ifDefined } from 'lit/directives/if-defined.js'; import { Sib } from '../libs/Sib'; import { base_context, store } from '../libs/store/store'; import { NextMixin } from '../mixins/nextMixin'; import { ValidationMixin } from '../mixins/validationMixin'; -import { ifDefined } from 'lit/directives/if-defined.js'; import { html, render } from 'lit'; -import { ContextMixin } from '../mixins/contextMixin'; import { trackRenderAsync } from '../logger'; +import { ContextMixin } from '../mixins/contextMixin'; export const SolidMemberDelete = { name: 'solid-member-delete', diff --git a/src/components/solid-membership.ts b/src/components/solid-membership.ts index 3090d3e3..7acc47fd 100644 --- a/src/components/solid-membership.ts +++ b/src/components/solid-membership.ts @@ -4,9 +4,9 @@ import { NextMixin } from '../mixins/nextMixin'; import { ValidationMixin } from '../mixins/validationMixin'; import { html, render } from 'lit'; -import { ContextMixin } from '../mixins/contextMixin'; import { ifDefined } from 'lit/directives/if-defined.js'; import { trackRenderAsync } from '../logger'; +import { ContextMixin } from '../mixins/contextMixin'; export const SolidMembership = { name: 'solid-membership', diff --git a/src/components/solid-table.ts b/src/components/solid-table.ts index 2cd7f9b8..3946dc05 100644 --- a/src/components/solid-table.ts +++ b/src/components/solid-table.ts @@ -1,22 +1,22 @@ -import type { Resource } from '../mixins/interfaces'; import { Sib } from '../libs/Sib'; import { store } from '../libs/store/store'; -import { WidgetMixin } from '../mixins/widgetMixin'; -import { ListMixin } from '../mixins/listMixin'; -import { StoreMixin } from '../mixins/storeMixin'; -import { PaginateMixin } from '../mixins/paginateMixin'; -import { FilterMixin } from '../mixins/filterMixin'; import { CounterMixin } from '../mixins/counterMixin'; -import { SorterMixin } from '../mixins/sorterMixin'; -import { GrouperMixin } from '../mixins/grouperMixin'; import { FederationMixin } from '../mixins/federationMixin'; +import { FilterMixin } from '../mixins/filterMixin'; +import { GrouperMixin } from '../mixins/grouperMixin'; import { HighlighterMixin } from '../mixins/highlighterMixin'; +import type { Resource } from '../mixins/interfaces'; +import { ListMixin } from '../mixins/listMixin'; +import { PaginateMixin } from '../mixins/paginateMixin'; import { RequiredMixin } from '../mixins/requiredMixin'; +import { SorterMixin } from '../mixins/sorterMixin'; +import { StoreMixin } from '../mixins/storeMixin'; +import { WidgetMixin } from '../mixins/widgetMixin'; import { html, render } from 'lit'; import { until } from 'lit/directives/until.js'; -import { spread } from '../libs/lit-helpers'; import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import { spread } from '../libs/lit-helpers'; import { trackRenderAsync } from '../logger'; export const SolidTable = { diff --git a/src/components/solid-widget.ts b/src/components/solid-widget.ts index 98a4a6b9..05168032 100644 --- a/src/components/solid-widget.ts +++ b/src/components/solid-widget.ts @@ -1,11 +1,11 @@ +import { html, render } from 'lit'; +import { unsafeHTML } from 'lit/directives/unsafe-html.js'; import { Sib } from '../libs/Sib'; +import { evalTemplateString } from '../libs/helpers'; import { StoreMixin } from '../mixins/storeMixin'; +import { ActionMixin } from '../new-widgets/attributeMixins/actionMixin'; import { BaseWidgetMixin } from '../new-widgets/baseWidgetMixin'; import { FormMixin } from '../new-widgets/templatesDependencies/formMixin'; -import { ActionMixin } from '../new-widgets/attributeMixins/actionMixin'; -import { evalTemplateString } from '../libs/helpers'; -import { html, render } from 'lit'; -import { unsafeHTML } from 'lit/directives/unsafe-html.js'; export const SolidWidget = { name: 'solid-widget', diff --git a/src/index.ts b/src/index.ts index 8c3a6726..3feed9f0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,16 +1,16 @@ import './libs/polyfills.js'; +import { SolidAcChecker } from './components/solid-ac-checker'; +import { SolidDelete } from './components/solid-delete'; // Components import { SolidDisplay } from './components/solid-display'; import { SolidForm } from './components/solid-form'; import { SolidFormSearch } from './components/solid-form-search'; -import { SolidWidget } from './components/solid-widget'; -import { SolidAcChecker } from './components/solid-ac-checker'; -import { SolidDelete } from './components/solid-delete'; import { SolidLang } from './components/solid-lang'; -import { SolidTable } from './components/solid-table'; -import { SolidMembership } from './components/solid-membership'; -import { SolidMemberDelete } from './components/solid-member-delete'; import { SolidMemberAdd } from './components/solid-member-add'; +import { SolidMemberDelete } from './components/solid-member-delete'; +import { SolidMembership } from './components/solid-membership'; +import { SolidTable } from './components/solid-table'; +import { SolidWidget } from './components/solid-widget'; // Mixins import { CounterMixin } from './mixins/counterMixin'; @@ -28,27 +28,27 @@ import { TranslationMixin } from './mixins/translationMixin'; import { ValidationMixin } from './mixins/validationMixin'; import { WidgetMixin } from './mixins/widgetMixin'; -// New widgets system -import { newWidgetFactory } from './new-widgets/new-widget-factory'; -import { BaseWidgetMixin } from './new-widgets/baseWidgetMixin'; import * as AttributeMixins from './new-widgets/attributeMixins'; +import { BaseWidgetMixin } from './new-widgets/baseWidgetMixin'; import * as CallbackMixins from './new-widgets/callbackMixins'; +// New widgets system +import { newWidgetFactory } from './new-widgets/new-widget-factory'; import * as TemplateAdditionMixins from './new-widgets/templateAdditionMixins'; import * as Templates from './new-widgets/templates'; import * as TemplatesDependenciesMixins from './new-widgets/templatesDependencies'; -// Libs -import { store, base_context as baseContext } from './libs/store/store'; import { Sib } from './libs/Sib'; +import * as Helpers from './libs/helpers'; +// Libs +import { base_context as baseContext, store } from './libs/store/store'; import SolidTemplateElement from './solid-template-element'; import { widgetFactory } from './widgets/widget-factory'; -import * as Helpers from './libs/helpers'; // lit-html import { html, render } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; -import { until } from 'lit/directives/until.js'; import { unsafeHTML } from 'lit/directives/unsafe-html.js'; +import { until } from 'lit/directives/until.js'; export { // Components diff --git a/src/libs/ComponentFactory.ts b/src/libs/ComponentFactory.ts index 26763334..b94f300a 100644 --- a/src/libs/ComponentFactory.ts +++ b/src/libs/ComponentFactory.ts @@ -1,11 +1,11 @@ -import { Compositor } from './Compositor'; import { Component } from './Component'; +import { Compositor } from './Compositor'; import type { - MixinStaticInterface, + AccessorStaticInterface, + ArrayOfHooksInterface, AttributesDefinitionInterface, ComponentConstructorInterface, - ArrayOfHooksInterface, - AccessorStaticInterface, + MixinStaticInterface, } from './interfaces'; export class ComponentFactory { diff --git a/src/libs/Compositor.ts b/src/libs/Compositor.ts index 6f631c8d..a0a8dbc4 100644 --- a/src/libs/Compositor.ts +++ b/src/libs/Compositor.ts @@ -1,9 +1,9 @@ import type { - MixinStaticInterface, - ComponentStaticInterface, - AttributesDefinitionInterface, - ArrayOfHooksInterface, AccessorStaticInterface, + ArrayOfHooksInterface, + AttributesDefinitionInterface, + ComponentStaticInterface, + MixinStaticInterface, } from './interfaces'; const HOOKS = ['created', 'attached', 'detached']; diff --git a/src/libs/filter.ts b/src/libs/filter.ts index ae66b07f..81589b39 100644 --- a/src/libs/filter.ts +++ b/src/libs/filter.ts @@ -1,7 +1,7 @@ import { - parseFieldsString, - findClosingBracketMatchIndex, compare, + findClosingBracketMatchIndex, + parseFieldsString, uniqID, } from './helpers'; import type { Query, SearchQuery } from './interfaces'; diff --git a/src/libs/lit-helpers.ts b/src/libs/lit-helpers.ts index 0d4730f6..01058697 100644 --- a/src/libs/lit-helpers.ts +++ b/src/libs/lit-helpers.ts @@ -4,22 +4,22 @@ */ import { - html, - type TemplateResult, - noChange, - type ChildPart, type AttributePart, type BooleanAttributePart, + type ChildPart, + type ElementPart, type EventPart, type PropertyPart, - type ElementPart, + type TemplateResult, + html, + noChange, } from 'lit'; import { - directive, Directive, type PartInfo, PartType, + directive, } from 'lit/directive.js'; type SpreadPartType = diff --git a/src/libs/store/custom-getter.ts b/src/libs/store/custom-getter.ts index 7e8fcccd..4d933167 100644 --- a/src/libs/store/custom-getter.ts +++ b/src/libs/store/custom-getter.ts @@ -1,6 +1,6 @@ import JSONLDContextParser from 'jsonld-context-parser'; -import { store } from './store'; import type { Resource } from '../../mixins/interfaces'; +import { store } from './store'; const ContextParser = JSONLDContextParser.ContextParser; diff --git a/src/mixins/counterMixin.ts b/src/mixins/counterMixin.ts index 21269aab..c981cd90 100644 --- a/src/mixins/counterMixin.ts +++ b/src/mixins/counterMixin.ts @@ -1,7 +1,7 @@ import { html } from 'lit'; import { unsafeHTML } from 'lit/directives/unsafe-html.js'; -import { evalTemplateString } from '../libs/helpers'; import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import { evalTemplateString } from '../libs/helpers'; const CounterMixin = { name: 'counter-mixin', diff --git a/src/mixins/filterMixin.ts b/src/mixins/filterMixin.ts index 2098ef0e..c9a57d11 100644 --- a/src/mixins/filterMixin.ts +++ b/src/mixins/filterMixin.ts @@ -1,7 +1,7 @@ -import type { SearchQuery } from '../libs/interfaces'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; import { searchInResources } from '../libs/filter'; +import type { SearchQuery } from '../libs/interfaces'; import type { ServerSearchOptions } from '../libs/store/server-search'; -import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const FilterMixin = { name: 'filter-mixin', diff --git a/src/mixins/grouperMixin.ts b/src/mixins/grouperMixin.ts index efc3cb98..5934bb20 100644 --- a/src/mixins/grouperMixin.ts +++ b/src/mixins/grouperMixin.ts @@ -1,5 +1,5 @@ -import { generalComparator } from '../libs/helpers'; import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import { generalComparator } from '../libs/helpers'; const GrouperMixin = { name: 'grouper-mixin', diff --git a/src/mixins/listMixin.ts b/src/mixins/listMixin.ts index 79564f7d..467b94d4 100644 --- a/src/mixins/listMixin.ts +++ b/src/mixins/listMixin.ts @@ -1,7 +1,7 @@ import { html, render } from 'lit'; -import { preHTML } from '../libs/lit-helpers'; import { ifDefined } from 'lit/directives/if-defined.js'; import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import { preHTML } from '../libs/lit-helpers'; const ListMixin = { name: 'list-mixin', diff --git a/src/mixins/paginateMixin.ts b/src/mixins/paginateMixin.ts index b379e485..6fae4f33 100644 --- a/src/mixins/paginateMixin.ts +++ b/src/mixins/paginateMixin.ts @@ -1,4 +1,4 @@ -import { html, type TemplateResult } from 'lit'; +import { type TemplateResult, html } from 'lit'; import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; const PaginateMixin = { diff --git a/src/mixins/storeMixin.ts b/src/mixins/storeMixin.ts index ea1d45c8..9cda3e75 100644 --- a/src/mixins/storeMixin.ts +++ b/src/mixins/storeMixin.ts @@ -1,13 +1,13 @@ -import { store } from '../libs/store/store'; +import { formatAttributesToServerPaginationOptions } from '../libs/store/server-pagination'; import { formatAttributesToServerSearchOptions, mergeServerSearchOptions, } from '../libs/store/server-search'; +import { store } from '../libs/store/store'; import { AttributeBinderMixin } from './attributeBinderMixin'; -import type { Resource } from './interfaces'; import { ContextMixin } from './contextMixin'; +import type { Resource } from './interfaces'; import { ServerPaginationMixin } from './serverPaginationMixin'; -import { formatAttributesToServerPaginationOptions } from '../libs/store/server-pagination'; const StoreMixin = { name: 'store-mixin', diff --git a/src/mixins/validationMixin.ts b/src/mixins/validationMixin.ts index d2b55238..e10fee95 100644 --- a/src/mixins/validationMixin.ts +++ b/src/mixins/validationMixin.ts @@ -2,8 +2,8 @@ import dialogPolyfill from 'dialog-polyfill'; import { html } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; import { uniqID } from '../libs/helpers'; -import { TranslationMixin } from './translationMixin'; import { preHTML } from '../libs/lit-helpers'; +import { TranslationMixin } from './translationMixin'; const ValidationMixin = { name: 'validation-mixin', diff --git a/src/mixins/widgetMixin.ts b/src/mixins/widgetMixin.ts index 56b187e5..426db26d 100644 --- a/src/mixins/widgetMixin.ts +++ b/src/mixins/widgetMixin.ts @@ -1,12 +1,12 @@ -import { spread, preHTML } from '../libs/lit-helpers'; +import { type TemplateResult, html, render } from 'lit'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { - parseFieldsString, findClosingBracketMatchIndex, + parseFieldsString, } from '../libs/helpers'; +import { preHTML, spread } from '../libs/lit-helpers'; import { newWidgetFactory } from '../new-widgets/new-widget-factory'; -import { type WidgetInterface, WidgetType, type Resource } from './interfaces'; -import { html, render, type TemplateResult } from 'lit'; -import { ifDefined } from 'lit/directives/if-defined.js'; +import { type Resource, type WidgetInterface, WidgetType } from './interfaces'; const WidgetMixin = { name: 'widget-mixin', diff --git a/src/new-widgets/attributeMixins/index.ts b/src/new-widgets/attributeMixins/index.ts index 9070a645..3ab60217 100644 --- a/src/new-widgets/attributeMixins/index.ts +++ b/src/new-widgets/attributeMixins/index.ts @@ -1,11 +1,11 @@ -import { MultipleMixin } from './multipleMixin'; import { ActionMixin } from './actionMixin'; import { BlankMixin } from './blankMixin'; -import { MailtoMixin } from './mailtoMixin'; -import { TelMixin } from './telMixin'; -import { PlaceholderMixin } from './placeholderMixin'; import { BooleanMixin } from './booleanMixin'; +import { MailtoMixin } from './mailtoMixin'; +import { MultipleMixin } from './multipleMixin'; import { NumberMixin } from './numberMixin'; +import { PlaceholderMixin } from './placeholderMixin'; +import { TelMixin } from './telMixin'; const attributeDirectory = { multiple: MultipleMixin, diff --git a/src/new-widgets/callbackMixins/autocompletionMixin.ts b/src/new-widgets/callbackMixins/autocompletionMixin.ts index 5945ac1f..0f9b54af 100644 --- a/src/new-widgets/callbackMixins/autocompletionMixin.ts +++ b/src/new-widgets/callbackMixins/autocompletionMixin.ts @@ -1,11 +1,11 @@ +import SlimSelect from 'slim-select'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; import { asyncQuerySelector, fuzzyCompare, importInlineCSS, } from '../../libs/helpers'; -import SlimSelect from 'slim-select'; import { TranslationMixin } from '../../mixins/translationMixin'; -import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; const AutocompletionMixin = { name: 'autocompletion-mixin', diff --git a/src/new-widgets/callbackMixins/richtextMixin.ts b/src/new-widgets/callbackMixins/richtextMixin.ts index f87cf2df..9ba42a6e 100644 --- a/src/new-widgets/callbackMixins/richtextMixin.ts +++ b/src/new-widgets/callbackMixins/richtextMixin.ts @@ -1,8 +1,8 @@ import Quill from 'quill'; import deltaMd from 'delta-markdown-for-quill'; -import { importInlineCSS } from '../../libs/helpers.js'; import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.js'; +import { importInlineCSS } from '../../libs/helpers.js'; const RichtextMixin = { name: 'richtext-mixin', diff --git a/src/new-widgets/new-widget-factory.ts b/src/new-widgets/new-widget-factory.ts index 9760f0f8..02c3f13e 100644 --- a/src/new-widgets/new-widget-factory.ts +++ b/src/new-widgets/new-widget-factory.ts @@ -1,18 +1,18 @@ import { Sib } from '../libs/Sib'; +import type { MixinStaticInterface } from '../libs/interfaces'; +import { attributeDirectory } from './attributeMixins/index'; import { BaseWidgetMixin } from './baseWidgetMixin'; +import { callbackDirectory } from './callbackMixins/index'; import type { Template, WidgetMixinsInterface } from './interfaces'; -import type { MixinStaticInterface } from '../libs/interfaces'; +import { templateAdditionDirectory } from './templateAdditionMixins/index'; import { defaultTemplates, displayTemplates, formTemplates, - setTemplates, groupTemplates, + setTemplates, } from './templates/index'; import { valueTransformationDirectory } from './valueTransformationMixins/index'; -import { templateAdditionDirectory } from './templateAdditionMixins/index'; -import { attributeDirectory } from './attributeMixins/index'; -import { callbackDirectory } from './callbackMixins/index'; const valueTransformationKeys = Object.keys(valueTransformationDirectory); const attributeKeys = Object.keys(attributeDirectory); diff --git a/src/new-widgets/templateAdditionMixins/index.ts b/src/new-widgets/templateAdditionMixins/index.ts index 7f3c163a..d0525f91 100644 --- a/src/new-widgets/templateAdditionMixins/index.ts +++ b/src/new-widgets/templateAdditionMixins/index.ts @@ -1,6 +1,6 @@ -import { LabelMixin } from './labelMixin'; -import { LabelLastMixin } from './labelLastMixin'; import { AddableMixin } from './addableMixin'; +import { LabelLastMixin } from './labelLastMixin'; +import { LabelMixin } from './labelMixin'; /** * DOM Additions diff --git a/src/new-widgets/templateAdditionMixins/labelMixin.ts b/src/new-widgets/templateAdditionMixins/labelMixin.ts index 338dfd5e..36b9e1cd 100644 --- a/src/new-widgets/templateAdditionMixins/labelMixin.ts +++ b/src/new-widgets/templateAdditionMixins/labelMixin.ts @@ -1,6 +1,6 @@ import { html } from 'lit'; -import { uniqID } from '../../libs/helpers'; import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import { uniqID } from '../../libs/helpers'; const LabelMixin = { name: 'label-mixin', diff --git a/src/new-widgets/templates/displayTemplatesDirectory.ts b/src/new-widgets/templates/displayTemplatesDirectory.ts index fb17056b..0b066316 100644 --- a/src/new-widgets/templates/displayTemplatesDirectory.ts +++ b/src/new-widgets/templates/displayTemplatesDirectory.ts @@ -1,5 +1,5 @@ -import { EditableMixin } from '../templatesDependencies/editableMixin'; import { AltMixin } from '../templatesDependencies/altMixin'; +import { EditableMixin } from '../templatesDependencies/editableMixin'; import { LinkTextMixin } from '../templatesDependencies/linkTextMixin'; import { html } from 'lit'; diff --git a/src/new-widgets/templates/formTemplatesDirectory.ts b/src/new-widgets/templates/formTemplatesDirectory.ts index 5c1cc1d1..734eeaa8 100644 --- a/src/new-widgets/templates/formTemplatesDirectory.ts +++ b/src/new-widgets/templates/formTemplatesDirectory.ts @@ -1,19 +1,19 @@ -import { FormMixin } from '../templatesDependencies/formMixin'; +import { FilterRangeFormMixin } from '../templatesDependencies/filterRangeFormMixin'; import { FormCheckboxMixin } from '../templatesDependencies/formCheckboxMixin'; +import { FormCheckboxesMixin } from '../templatesDependencies/formCheckboxesMixin'; +import { FormDropdownMixin } from '../templatesDependencies/formDropdownMixin'; +import { FormFileMixin } from '../templatesDependencies/formFileMixin'; +import { FormLengthMixin } from '../templatesDependencies/formLengthMixin'; import { FormMinMaxMixin } from '../templatesDependencies/formMinMaxMixin'; +import { FormMixin } from '../templatesDependencies/formMixin'; import { FormNumberMixin } from '../templatesDependencies/formNumberMixin'; -import { FormDropdownMixin } from '../templatesDependencies/formDropdownMixin'; -import { FormCheckboxesMixin } from '../templatesDependencies/formCheckboxesMixin'; import { FormRadioMixin } from '../templatesDependencies/formRadioMixin'; -import { FormFileMixin } from '../templatesDependencies/formFileMixin'; +import { FormStepMixin } from '../templatesDependencies/formStepMixin'; import { MultipleFormMixin } from '../templatesDependencies/multipleFormMixin'; import { MultipleselectFormMixin } from '../templatesDependencies/multipleselectFormMixin'; +import { PatternMixin } from '../templatesDependencies/patternMixin'; import { RangeMixin } from '../templatesDependencies/rangeMixin'; -import { FilterRangeFormMixin } from '../templatesDependencies/filterRangeFormMixin'; import { ValueRichtextMixin } from '../templatesDependencies/valueRichtextMixin'; -import { PatternMixin } from '../templatesDependencies/patternMixin'; -import { FormStepMixin } from '../templatesDependencies/formStepMixin'; -import { FormLengthMixin } from '../templatesDependencies/formLengthMixin'; import { html } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; diff --git a/src/new-widgets/templates/index.ts b/src/new-widgets/templates/index.ts index 853d1383..ceb4a416 100644 --- a/src/new-widgets/templates/index.ts +++ b/src/new-widgets/templates/index.ts @@ -1,8 +1,8 @@ import { defaultTemplates } from './defaultTemplatesDirectory'; import { displayTemplates } from './displayTemplatesDirectory'; import { formTemplates } from './formTemplatesDirectory'; -import { setTemplates } from './setTemplatesDirectory'; import { groupTemplates } from './groupTemplatesDirectory.js'; +import { setTemplates } from './setTemplatesDirectory'; export { defaultTemplates, diff --git a/src/new-widgets/templatesDependencies/editableMixin.ts b/src/new-widgets/templatesDependencies/editableMixin.ts index fa59c7a7..2497236c 100644 --- a/src/new-widgets/templatesDependencies/editableMixin.ts +++ b/src/new-widgets/templatesDependencies/editableMixin.ts @@ -1,5 +1,5 @@ -import { StoreMixin } from '../../mixins/storeMixin'; import { store } from '../../libs/store/store'; +import { StoreMixin } from '../../mixins/storeMixin'; import { html } from 'lit'; import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; diff --git a/src/new-widgets/templatesDependencies/index.ts b/src/new-widgets/templatesDependencies/index.ts index 04a0ed31..eaf1987a 100644 --- a/src/new-widgets/templatesDependencies/index.ts +++ b/src/new-widgets/templatesDependencies/index.ts @@ -1,8 +1,8 @@ import { AltMixin } from './altMixin'; import { EditableMixin } from './editableMixin'; import { FilterRangeFormMixin } from './filterRangeFormMixin'; -import { FormCheckboxesMixin } from './formCheckboxesMixin'; import { FormCheckboxMixin } from './formCheckboxMixin'; +import { FormCheckboxesMixin } from './formCheckboxesMixin'; import { FormDropdownMixin } from './formDropdownMixin'; import { FormFileMixin } from './formFileMixin'; import { FormLengthMixin } from './formLengthMixin'; diff --git a/src/new-widgets/templatesDependencies/rangeMixin.ts b/src/new-widgets/templatesDependencies/rangeMixin.ts index d3e0a6c3..0133e8b5 100644 --- a/src/new-widgets/templatesDependencies/rangeMixin.ts +++ b/src/new-widgets/templatesDependencies/rangeMixin.ts @@ -1,9 +1,9 @@ +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; import { base_context, store } from '../../libs/store/store'; -import { StoreMixin } from '../../mixins/storeMixin'; -import { SorterMixin } from '../../mixins/sorterMixin'; import { FederationMixin } from '../../mixins/federationMixin'; import type { Resource } from '../../mixins/interfaces'; -import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import { SorterMixin } from '../../mixins/sorterMixin'; +import { StoreMixin } from '../../mixins/storeMixin'; const RangeMixin = { name: 'range-mixin', diff --git a/src/new-widgets/valueTransformationMixins/index.ts b/src/new-widgets/valueTransformationMixins/index.ts index af40ff7a..032ae31d 100644 --- a/src/new-widgets/valueTransformationMixins/index.ts +++ b/src/new-widgets/valueTransformationMixins/index.ts @@ -1,9 +1,9 @@ +import { AutolinkMixin } from './autolinkMixin'; import { DateMixin } from './dateMixin'; import { DateTimeMixin } from './dateTimeMixin'; -import { MultilineMixin } from './multilineMixin'; import { MarkdownMixin } from './markdownMixin.js'; +import { MultilineMixin } from './multilineMixin'; import { OembedMixin } from './oembedMixin'; -import { AutolinkMixin } from './autolinkMixin'; const valueTransformationDirectory = { date: DateMixin, diff --git a/src/widgets/widget-factory.ts b/src/widgets/widget-factory.ts index f2fd5d20..fad6eeb0 100644 --- a/src/widgets/widget-factory.ts +++ b/src/widgets/widget-factory.ts @@ -1,5 +1,5 @@ -import { BaseWidget } from './baseWidget'; import { defineComponent } from '../libs/helpers'; +import { BaseWidget } from './baseWidget'; export const widgetFactory = ( tagName: string, -- GitLab From 49662eaba7ce8145c1b8930cee87f1546f72d2f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Thu, 21 Nov 2024 22:11:53 +0100 Subject: [PATCH 40/66] fix `lint/complexity/useLiteralKeys` --- biome.jsonc | 1 - cypress/e2e/e2e/widgets-form.cy.ts | 24 ++++++------- cypress/e2e/unit/Compositor.cy.ts | 4 +-- cypress/e2e/unit/store.cy.ts | 8 ++--- server.js | 2 +- src/components/solid-display.ts | 6 ++-- src/components/solid-form-search.ts | 6 ++-- src/libs/store/custom-getter.ts | 8 ++--- src/libs/store/store.ts | 6 ++-- src/mixins/filterMixin.ts | 6 ++-- src/mixins/requiredMixin.ts | 2 +- src/mixins/sorterMixin.ts | 2 +- src/mixins/storeMixin.ts | 2 +- src/mixins/widgetMixin.ts | 8 ++--- src/new-widgets/attributeMixins/blankMixin.ts | 2 +- .../attributeMixins/mailtoMixin.ts | 2 +- .../attributeMixins/placeholderMixin.ts | 2 +- src/new-widgets/attributeMixins/telMixin.ts | 2 +- .../templateAdditionMixins/labelMixin.ts | 4 +-- .../templatesDependencies/editableMixin.ts | 2 +- .../formCheckboxesMixin.ts | 6 ++-- .../formDropdownMixin.ts | 16 ++++----- .../templatesDependencies/formFileMixin.ts | 28 +++++++-------- .../templatesDependencies/formMixin.ts | 4 +-- .../templatesDependencies/formRadioMixin.ts | 2 +- .../multipleFormMixin.ts | 36 +++++++++---------- .../multipleselectFormMixin.ts | 12 +++---- .../templatesDependencies/rangeMixin.ts | 8 ++--- .../valueTransformationMixins/dateMixin.ts | 4 +-- src/widgets/baseWidget.ts | 8 ++--- 30 files changed, 110 insertions(+), 113 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index 5cb4acea..d10fc219 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -26,7 +26,6 @@ "useTemplate": "off" }, "complexity": { - "useLiteralKeys": "off", "noForEach": "off", "noBannedTypes": "off", "useOptionalChain": "off", diff --git a/cypress/e2e/e2e/widgets-form.cy.ts b/cypress/e2e/e2e/widgets-form.cy.ts index f4c6b145..9d755fc3 100644 --- a/cypress/e2e/e2e/widgets-form.cy.ts +++ b/cypress/e2e/e2e/widgets-form.cy.ts @@ -26,7 +26,7 @@ describe('form widgets', { testIsolation: false }, function () { cy.get('solid-form-text').then($el => { // Check API - expect((<any>$el[0]).component['value']).to.equal('test value 1'); // value attribute + expect((<any>$el[0]).component.value).to.equal('test value 1'); // value attribute expect((<any>$el[0]).component.getValue()).to.equal('new value'); // form value }); @@ -80,7 +80,7 @@ describe('form widgets', { testIsolation: false }, function () { cy.get('solid-form-textarea').then($el => { // Check API - expect((<any>$el[0]).component['value']).to.equal('test value 1'); // value attribute + expect((<any>$el[0]).component.value).to.equal('test value 1'); // value attribute expect((<any>$el[0]).component.getValue()).to.equal('new value'); // form value }); @@ -107,7 +107,7 @@ describe('form widgets', { testIsolation: false }, function () { cy.get('solid-form-checkbox').then($el => { // Check API - expect((<any>$el[0]).component['value']).to.equal('true'); // value attribute + expect((<any>$el[0]).component.value).to.equal('true'); // value attribute expect((<any>$el[0]).component.getValue()).to.equal(true); // form value }); @@ -117,7 +117,7 @@ describe('form widgets', { testIsolation: false }, function () { cy.get('solid-form-checkbox').then($el => { // Check API - expect((<any>$el[0]).component['value']).to.equal('true'); // value attribute + expect((<any>$el[0]).component.value).to.equal('true'); // value attribute expect((<any>$el[0]).component.getValue()).to.equal(false); // form value }); }); @@ -141,7 +141,7 @@ describe('form widgets', { testIsolation: false }, function () { // Check API cy.get('solid-form-date#test1').then($el => { - expect((<any>$el[0]).component['value']).to.equal('2020-05-21'); // value attribute + expect((<any>$el[0]).component.value).to.equal('2020-05-21'); // value attribute expect((<any>$el[0]).component.getValue()).to.equal('2020-12-31'); // form value }); @@ -175,7 +175,7 @@ describe('form widgets', { testIsolation: false }, function () { cy.get('solid-form-number').then($el => { // Check API - expect((<any>$el[0]).component['value']).to.equal('5'); // value attribute + expect((<any>$el[0]).component.value).to.equal('5'); // value attribute expect((<any>$el[0]).component.getValue()).to.equal(8); // form value }); @@ -216,7 +216,7 @@ describe('form widgets', { testIsolation: false }, function () { cy.get('solid-form-email').then($el => { // Check API - expect((<any>$el[0]).component['value']).to.equal('test@test.com'); // value attribute + expect((<any>$el[0]).component.value).to.equal('test@test.com'); // value attribute expect((<any>$el[0]).component.getValue()).to.equal('new@example.com'); // form value }); }); @@ -241,7 +241,7 @@ describe('form widgets', { testIsolation: false }, function () { cy.get('solid-form-hidden').then($el => { // Check API - expect((<any>$el[0]).component['value']).to.equal('test value 1'); // value attribute + expect((<any>$el[0]).component.value).to.equal('test value 1'); // value attribute expect((<any>$el[0]).component.getValue()).to.equal('new value'); // form value }); }); @@ -284,7 +284,7 @@ describe('form widgets', { testIsolation: false }, function () { cy.get('solid-form-dropdown#test1').then($el => { // Check API - expect((<any>$el[0]).component['value']).to.equal(''); // value attribute + expect((<any>$el[0]).component.value).to.equal(''); // value attribute expect((<any>$el[0]).component.getValue()).to.equal( '{"@id": "/examples/data/list/skill-2.jsonld"}', ); // form value @@ -298,7 +298,7 @@ describe('form widgets', { testIsolation: false }, function () { '{"@id": "/examples/data/list/skill-2.jsonld"}', ); cy.get('solid-form-dropdown#test2').then($el => { - expect((<any>$el[0]).component['value']).to.equal( + expect((<any>$el[0]).component.value).to.equal( '/examples/data/list/skill-2.jsonld', ); // value attribute expect((<any>$el[0]).component.getValue()).to.equal( @@ -465,7 +465,7 @@ describe('form widgets', { testIsolation: false }, function () { cy.get('solid-form-radio#test1').then($el => { // Check API - expect((<any>$el[0]).component['value']).to.equal(''); // value attribute + expect((<any>$el[0]).component.value).to.equal(''); // value attribute expect((<any>$el[0]).component.getValue()).to.equal( '{"@id": "/examples/data/list/skill-2.jsonld"}', ); // form value @@ -479,7 +479,7 @@ describe('form widgets', { testIsolation: false }, function () { .find('input') .should('have.attr', 'checked', 'checked'); cy.get('solid-form-radio#test2').then($el => { - expect((<any>$el[0]).component['value']).to.equal( + expect((<any>$el[0]).component.value).to.equal( '/examples/data/list/skill-3.jsonld', ); // value attribute expect((<any>$el[0]).component.getValue()).to.equal( diff --git a/cypress/e2e/unit/Compositor.cy.ts b/cypress/e2e/unit/Compositor.cy.ts index 2c3f9d47..f31b3423 100644 --- a/cypress/e2e/unit/Compositor.cy.ts +++ b/cypress/e2e/unit/Compositor.cy.ts @@ -162,13 +162,13 @@ describe('Mixin Compositor', () => { expect(typeof result[accessorName].set).eq('function'); }); - expect(result['accessorTest'].get.toString()).eq( + expect(result.accessorTest.get.toString()).eq( Reflect.getOwnPropertyDescriptor( component, 'accessorTest', )!.get!.toString(), ); - expect(result['accessorTest'].set.toString()).eq( + expect(result.accessorTest.set.toString()).eq( Reflect.getOwnPropertyDescriptor( MixinTestOne, 'accessorTest', diff --git a/cypress/e2e/unit/store.cy.ts b/cypress/e2e/unit/store.cy.ts index d2646dc3..1084419f 100644 --- a/cypress/e2e/unit/store.cy.ts +++ b/cypress/e2e/unit/store.cy.ts @@ -59,7 +59,7 @@ describe('store', { testIsolation: false }, function () { }; await store.setLocalData(dataToSave1, url); const dataRead1 = await store.getData(url); - expect(await dataRead1!['foo']).eq('bar'); + expect(await dataRead1!.foo).eq('bar'); store.clearCache(url); }); }); @@ -81,8 +81,8 @@ describe('store', { testIsolation: false }, function () { '/examples/data/list/user-1.jsonld', ); const dataRead = store.get('/examples/data/list/user-1.jsonld'); - expect(await dataRead['username']).eq('local user'); - expect(await dataRead['email']).not.exist; + expect(await dataRead.username).eq('local user'); + expect(await dataRead.email).not.exist; store.clearCache('/examples/data/list/user-1.jsonld'); }); }); @@ -644,7 +644,7 @@ describe('store', { testIsolation: false }, function () { cy.wait(100).then(async () => { const resource = store.get('store://local.2'); expect(resource).to.exist; - const name = await resource['name']; + const name = await resource.name; expect(name).to.equal('ok'); }); }); diff --git a/server.js b/server.js index 239e1afa..c931f874 100644 --- a/server.js +++ b/server.js @@ -44,7 +44,7 @@ process.env.ELECTRON_EXTRA_LAUNCH_ARGS = '--lang=en'; ); const data = JSON.parse(jsonData); const list = data['ldp:contains'].filter(user => - user['first_name'].toLowerCase().includes(val.toLowerCase()), + user.first_name.toLowerCase().includes(val.toLowerCase()), ); data['ldp:contains'] = limit ? list.slice(offset, offset + limit) : list; diff --git a/src/components/solid-display.ts b/src/components/solid-display.ts index f32959c6..a3abe0c2 100644 --- a/src/components/solid-display.ts +++ b/src/components/solid-display.ts @@ -49,7 +49,7 @@ export const SolidDisplay = { const route = document.querySelector('solid-route[active]') as any; if (!route) return; setTimeout(() => { - if (route['resourceId'] === this.resourceId) this.addActiveCallback(); + if (route.resourceId === this.resourceId) this.addActiveCallback(); }); }, detached(): void { @@ -188,8 +188,8 @@ export const SolidDisplay = { if (attr.name.startsWith('child-')) attributes[attr.name.replace(/^child-/, '')] = attr.value; if (attr.name === 'next') { - attributes['role'] = 'button'; - attributes['tabindex'] = '0'; + attributes.role = 'button'; + attributes.tabindex = '0'; } } return attributes; diff --git a/src/components/solid-form-search.ts b/src/components/solid-form-search.ts index 0045f216..223e26be 100644 --- a/src/components/solid-form-search.ts +++ b/src/components/solid-form-search.ts @@ -127,11 +127,9 @@ export const SolidFormSearch = { }, async updateAutoRanges() { for (const attr of (this.element as Element).attributes) { - if (!attr['name'].startsWith('auto-range-')) continue; + if (!attr.name.startsWith('auto-range-')) continue; const fieldName = - attr.value !== '' - ? attr.value - : attr['name'].replace('auto-range-', ''); + attr.value !== '' ? attr.value : attr.name.replace('auto-range-', ''); const autoRangeValues = new Set(); for (const elm of this.attachedElements) { for (const value of await elm.getValuesOfField(fieldName)) { diff --git a/src/libs/store/custom-getter.ts b/src/libs/store/custom-getter.ts index 4d933167..4352022a 100644 --- a/src/libs/store/custom-getter.ts +++ b/src/libs/store/custom-getter.ts @@ -193,12 +193,12 @@ export class CustomGetter { this.resource['@type'].includes(type), ); return this.containerTypes.includes(this.resource['@type']); - } else if (this.resource['type']) { - if (Array.isArray(this.resource['type'])) + } else if (this.resource.type) { + if (Array.isArray(this.resource.type)) return this.containerTypes.some(type => - this.resource['type'].includes(type), + this.resource.type.includes(type), ); - return this.containerTypes.includes(this.resource['type']); + return this.containerTypes.includes(this.resource.type); } return false; diff --git a/src/libs/store/store.ts b/src/libs/store/store.ts index 512723f7..8a9871b7 100644 --- a/src/libs/store/store.ts +++ b/src/libs/store/store.ts @@ -260,8 +260,8 @@ class Store { flattenedResources.map(r => jsonld.compact(r, {})), ); for (const resource of compactedResources) { - const id = resource['@id'] || resource['id']; - let key = resource['@id'] || resource['id']; + const id = resource['@id'] || resource.id; + let key = resource['@id'] || resource.id; if (!key) console.log('No key or id for resource:', resource); if (key === '/') key = parentId; @@ -345,7 +345,7 @@ class Store { subscribeChildren(container: CustomGetter, containerId: string) { if (!container['ldp:contains']) return; for (const res of container['ldp:contains']) { - this.subscribeResourceTo(containerId, res['@id'] || res['id']); + this.subscribeResourceTo(containerId, res['@id'] || res.id); } } diff --git a/src/mixins/filterMixin.ts b/src/mixins/filterMixin.ts index c9a57d11..a71b9201 100644 --- a/src/mixins/filterMixin.ts +++ b/src/mixins/filterMixin.ts @@ -171,10 +171,10 @@ const FilterMixin = { //pass attributes to search form const searchAttributes = Array.from((this.element as Element).attributes) - .filter(attr => attr['name'].startsWith('search-')) + .filter(attr => attr.name.startsWith('search-')) .map(attr => ({ - name: attr['name'].replace('search-', ''), - value: attr['value'], + name: attr.name.replace('search-', ''), + value: attr.value, })); searchAttributes.forEach(({ name, value }) => { diff --git a/src/mixins/requiredMixin.ts b/src/mixins/requiredMixin.ts index dc4f79e5..5c12b8ae 100644 --- a/src/mixins/requiredMixin.ts +++ b/src/mixins/requiredMixin.ts @@ -21,7 +21,7 @@ const RequiredMixin = { .map(attr => { return attr.value !== '' ? attr.value - : attr['name'].replace('required-', ''); + : attr.name.replace('required-', ''); }); if (requiredFields.length) { diff --git a/src/mixins/sorterMixin.ts b/src/mixins/sorterMixin.ts index 2f88089f..e01a7b23 100644 --- a/src/mixins/sorterMixin.ts +++ b/src/mixins/sorterMixin.ts @@ -85,7 +85,7 @@ const SorterMixin = { if (!this.sortForm.component.value.field) { console.warn('The attribute field does not exist'); } else { - sortingKey = this.sortForm.component.value.field['value']; + sortingKey = this.sortForm.component.value.field.value; } const orderField = this.sortForm.component.value.order; orderValueToSort = diff --git a/src/mixins/storeMixin.ts b/src/mixins/storeMixin.ts index 9cda3e75..b6a6201a 100644 --- a/src/mixins/storeMixin.ts +++ b/src/mixins/storeMixin.ts @@ -26,7 +26,7 @@ const StoreMixin = { callback: async function (value: string) { const filteredOnServer = this.element.attributes['filtered-on']?.value === 'server'; - const limited = this.element.attributes['limit']?.value !== undefined; + const limited = this.element.attributes.limit?.value !== undefined; if (this.noRender === null && !filteredOnServer && !limited) { await this.fetchData(value); diff --git a/src/mixins/widgetMixin.ts b/src/mixins/widgetMixin.ts index 426db26d..a94efcc8 100644 --- a/src/mixins/widgetMixin.ts +++ b/src/mixins/widgetMixin.ts @@ -343,9 +343,9 @@ const WidgetMixin = { const resourceId = resource ? resource!['@id'] : null; if (this.multiple(escapedField)) - attrs['widget'] = this.getWidget(escapedField).tagName; + attrs.widget = this.getWidget(escapedField).tagName; if (this.getAction(escapedField) && resourceId) - attrs['src'] = + attrs.src = this.element.getAttribute('src-' + escapedField) || resourceId; if (this.editable(escapedField) && resourceId) attrs['value-id'] = resourceId; @@ -399,11 +399,11 @@ const WidgetMixin = { } catch (e) {} // in any case, set value attribute - attributes['value'] = value; + attributes.value = value; } } else { // otherwise, set value attribute - attributes['value'] = value; + attributes.value = value; } // Subscribe widgets if they show a resource diff --git a/src/new-widgets/attributeMixins/blankMixin.ts b/src/new-widgets/attributeMixins/blankMixin.ts index b310e86d..5e3569cd 100644 --- a/src/new-widgets/attributeMixins/blankMixin.ts +++ b/src/new-widgets/attributeMixins/blankMixin.ts @@ -1,7 +1,7 @@ const BlankMixin = { name: 'blank-mixin', created() { - this.listAttributes['target'] = '_blank'; + this.listAttributes.target = '_blank'; }, }; diff --git a/src/new-widgets/attributeMixins/mailtoMixin.ts b/src/new-widgets/attributeMixins/mailtoMixin.ts index 0a8471f0..b500c742 100644 --- a/src/new-widgets/attributeMixins/mailtoMixin.ts +++ b/src/new-widgets/attributeMixins/mailtoMixin.ts @@ -1,7 +1,7 @@ const MailtoMixin = { name: 'mailto-mixin', created() { - this.listAttributes['mailto'] = 'mailto:'; + this.listAttributes.mailto = 'mailto:'; }, }; diff --git a/src/new-widgets/attributeMixins/placeholderMixin.ts b/src/new-widgets/attributeMixins/placeholderMixin.ts index 54446fca..aee2ef30 100644 --- a/src/new-widgets/attributeMixins/placeholderMixin.ts +++ b/src/new-widgets/attributeMixins/placeholderMixin.ts @@ -10,7 +10,7 @@ const PlaceholderMixin = { }, }, attached() { - this.listAttributes['placeholder'] = + this.listAttributes.placeholder = this.placeholder || this.label || this.name || ''; }, }; diff --git a/src/new-widgets/attributeMixins/telMixin.ts b/src/new-widgets/attributeMixins/telMixin.ts index 5d1530f8..3582ace3 100644 --- a/src/new-widgets/attributeMixins/telMixin.ts +++ b/src/new-widgets/attributeMixins/telMixin.ts @@ -1,7 +1,7 @@ const TelMixin = { name: 'tel-mixin', created() { - this.listAttributes['tel'] = 'tel:'; + this.listAttributes.tel = 'tel:'; }, }; diff --git a/src/new-widgets/templateAdditionMixins/labelMixin.ts b/src/new-widgets/templateAdditionMixins/labelMixin.ts index 36b9e1cd..22858d3b 100644 --- a/src/new-widgets/templateAdditionMixins/labelMixin.ts +++ b/src/new-widgets/templateAdditionMixins/labelMixin.ts @@ -5,14 +5,14 @@ import { uniqID } from '../../libs/helpers'; const LabelMixin = { name: 'label-mixin', created() { - this.listAttributes['id'] = uniqID(); + this.listAttributes.id = uniqID(); this.listTemplateAdditions.attach( this.addLabel.bind(this), 'LabelMixin:addLabel', ); }, addLabel(template, listTemplateAdditions: PostProcessorRegistry) { - const newTemplate = html`<label for="${this.listAttributes['id']}">${this.label || this.name}</label>${template}`; + const newTemplate = html`<label for="${this.listAttributes.id}">${this.label || this.name}</label>${template}`; const nextProcessor = listTemplateAdditions.shift(); if (nextProcessor) nextProcessor(newTemplate, listTemplateAdditions); diff --git a/src/new-widgets/templatesDependencies/editableMixin.ts b/src/new-widgets/templatesDependencies/editableMixin.ts index 2497236c..f2d57dd7 100644 --- a/src/new-widgets/templatesDependencies/editableMixin.ts +++ b/src/new-widgets/templatesDependencies/editableMixin.ts @@ -12,7 +12,7 @@ const EditableMixin = { type: Boolean, default: null, callback: function (newValue: boolean) { - if (newValue !== null) this.listAttributes['editable'] = true; + if (newValue !== null) this.listAttributes.editable = true; }, }, valueId: { diff --git a/src/new-widgets/templatesDependencies/formCheckboxesMixin.ts b/src/new-widgets/templatesDependencies/formCheckboxesMixin.ts index 60666f56..16847a69 100644 --- a/src/new-widgets/templatesDependencies/formCheckboxesMixin.ts +++ b/src/new-widgets/templatesDependencies/formCheckboxesMixin.ts @@ -7,10 +7,10 @@ const FormCheckboxesMixin = { callback: function (value: string) { if (!value) return; try { - this.listAttributes['values'] = JSON.parse(value); + this.listAttributes.values = JSON.parse(value); } catch (e) { console.error(e); - this.listAttributes['values'] = []; + this.listAttributes.values = []; } this.render(); this.element.dispatchEvent(new Event('change')); @@ -18,7 +18,7 @@ const FormCheckboxesMixin = { }, }, created() { - this.listAttributes['values'] = []; + this.listAttributes.values = []; }, getValue() { const options = Array.from( diff --git a/src/new-widgets/templatesDependencies/formDropdownMixin.ts b/src/new-widgets/templatesDependencies/formDropdownMixin.ts index 18f3d305..e850778b 100644 --- a/src/new-widgets/templatesDependencies/formDropdownMixin.ts +++ b/src/new-widgets/templatesDependencies/formDropdownMixin.ts @@ -8,10 +8,10 @@ const FormDropdownMixin = { callback: function (value) { if (value) { try { - this.listAttributes['values'] = JSON.parse(value); + this.listAttributes.values = JSON.parse(value); } catch (e) { console.error(e); - this.listAttributes['values'] = []; + this.listAttributes.values = []; } this.render(); // use render to make sure the dispatch always happen after this.dispatchChange(); @@ -27,15 +27,15 @@ const FormDropdownMixin = { }, }, created() { - this.listAttributes['values'] = []; + this.listAttributes.values = []; if ( - this.listAttributes['value'] && - !JSON.parse(this.listAttributes['value']['@id']) && - Array.isArray(JSON.parse(this.listAttributes['value'])) + this.listAttributes.value && + !JSON.parse(this.listAttributes.value['@id']) && + Array.isArray(JSON.parse(this.listAttributes.value)) ) { - this.listAttributes['values'] = this.listAttributes['value']; + this.listAttributes.values = this.listAttributes.value; } - if (this.multiple) this.listAttributes['multiple'] = true; + if (this.multiple) this.listAttributes.multiple = true; }, dispatchChange() { if (!this.element.querySelector('select')) return; diff --git a/src/new-widgets/templatesDependencies/formFileMixin.ts b/src/new-widgets/templatesDependencies/formFileMixin.ts index 4296e530..515cfc61 100644 --- a/src/new-widgets/templatesDependencies/formFileMixin.ts +++ b/src/new-widgets/templatesDependencies/formFileMixin.ts @@ -12,10 +12,10 @@ const FormFileMixin = { initialValue: '', }, created() { - this.listAttributes['output'] = ''; - this.listAttributes['resetButtonHidden'] = true; - this.listAttributes['selectFile'] = this.selectFile.bind(this); - this.listAttributes['resetFile'] = this.resetFile.bind(this); + this.listAttributes.output = ''; + this.listAttributes.resetButtonHidden = true; + this.listAttributes.selectFile = this.selectFile.bind(this); + this.listAttributes.resetFile = this.resetFile.bind(this); }, attached() { this.element @@ -35,7 +35,7 @@ const FormFileMixin = { if (this.initialValue !== '') { this.value = this.initialValue; } - this.listAttributes['resetButtonHidden'] = true; + this.listAttributes.resetButtonHidden = true; this.planRender(); const dataHolder = this.element.querySelector('input[data-holder]'); dataHolder.value = this.value; @@ -53,7 +53,7 @@ const FormFileMixin = { if (filePicker.files!.length < 1) return; const dataHolder = this.element.querySelector('input[data-holder]'); - this.listAttributes['output'] = 'â³'; + this.listAttributes.output = 'â³'; this.planRender(); const file = filePicker.files![0]; @@ -66,8 +66,8 @@ const FormFileMixin = { }) .then(response => this.updateFile(dataHolder, response)) .catch(error => { - this.listAttributes['fileValue'] = ''; - this.listAttributes['output'] = 'upload error'; + this.listAttributes.fileValue = ''; + this.listAttributes.output = 'upload error'; this.planRender(); console.error(error); }); @@ -76,11 +76,11 @@ const FormFileMixin = { updateFile(dataHolder: HTMLInputElement, response: Response) { const location = response.headers.get('location'); if (location == null) { - this.listAttributes['output'] = 'header location not found!'; + this.listAttributes.output = 'header location not found!'; } else { this.value = location; - this.listAttributes['output'] = ''; - this.listAttributes['resetButtonHidden'] = false; + this.listAttributes.output = ''; + this.listAttributes.resetButtonHidden = false; dataHolder.value = location; dataHolder.dispatchEvent(new Event('change')); @@ -99,9 +99,9 @@ const FormFileMixin = { filePicker.value = dataHolder.value = ''; } - this.listAttributes['fileValue'] = ''; - this.listAttributes['output'] = ''; - this.listAttributes['resetButtonHidden'] = true; + this.listAttributes.fileValue = ''; + this.listAttributes.output = ''; + this.listAttributes.resetButtonHidden = true; dataHolder.dispatchEvent(new Event('change')); this.planRender(); }, diff --git a/src/new-widgets/templatesDependencies/formMixin.ts b/src/new-widgets/templatesDependencies/formMixin.ts index 7ebf9384..fc88faac 100644 --- a/src/new-widgets/templatesDependencies/formMixin.ts +++ b/src/new-widgets/templatesDependencies/formMixin.ts @@ -5,7 +5,7 @@ const FormMixin = { type: Boolean, default: false, callback: function () { - this.listAttributes['required'] = true; + this.listAttributes.required = true; }, }, autocomplete: { @@ -17,7 +17,7 @@ const FormMixin = { }, }, attached() { - this.listAttributes['onChange'] = this.onChange.bind(this); + this.listAttributes.onChange = this.onChange.bind(this); }, onChange(e: Event) { e.preventDefault(); diff --git a/src/new-widgets/templatesDependencies/formRadioMixin.ts b/src/new-widgets/templatesDependencies/formRadioMixin.ts index ba012562..7b1feb29 100644 --- a/src/new-widgets/templatesDependencies/formRadioMixin.ts +++ b/src/new-widgets/templatesDependencies/formRadioMixin.ts @@ -3,7 +3,7 @@ import { uniqID } from '../../libs/helpers'; const FormRadioMixin = { name: 'form-radio-mixin', created() { - this.listAttributes['id'] = uniqID(); + this.listAttributes.id = uniqID(); }, getValue() { const checkedElement = this.element.querySelector( diff --git a/src/new-widgets/templatesDependencies/multipleFormMixin.ts b/src/new-widgets/templatesDependencies/multipleFormMixin.ts index fb0a20f6..b404da84 100644 --- a/src/new-widgets/templatesDependencies/multipleFormMixin.ts +++ b/src/new-widgets/templatesDependencies/multipleFormMixin.ts @@ -13,8 +13,8 @@ const MultipleFormMixin = { type: String, default: '+', callback: function (value) { - if (value !== this.listAttributes['addLabel']) - this.listAttributes['addLabel'] = value; + if (value !== this.listAttributes.addLabel) + this.listAttributes.addLabel = value; this.planRender(); }, }, @@ -22,8 +22,8 @@ const MultipleFormMixin = { type: String, default: '×', callback: function (value) { - if (value !== this.listAttributes['removeLabel']) - this.listAttributes['removeLabel'] = value; + if (value !== this.listAttributes.removeLabel) + this.listAttributes.removeLabel = value; this.planRender(); }, }, @@ -35,8 +35,8 @@ const MultipleFormMixin = { type: String, default: undefined, callback: function (value) { - if (value !== this.listAttributes['addClass']) - this.listAttributes['addClass'] = value; + if (value !== this.listAttributes.addClass) + this.listAttributes.addClass = value; this.planRender(); }, }, @@ -44,8 +44,8 @@ const MultipleFormMixin = { type: String, default: undefined, callback: function (value) { - if (value !== this.listAttributes['removeClass']) - this.listAttributes['removeClass'] = value; + if (value !== this.listAttributes.removeClass) + this.listAttributes.removeClass = value; this.planRender(); }, }, @@ -56,16 +56,16 @@ const MultipleFormMixin = { 'MultipleFormMixin:setDataSrc', ); - this.listAttributes['children'] = []; - this.listAttributes['addLabel'] = this.addLabel; - this.listAttributes['removeLabel'] = this.removeLabel; - this.listAttributes['addClass'] = this.addClass; - this.listAttributes['removeClass'] = this.removeClass; - this.listAttributes['addItem'] = () => { + this.listAttributes.children = []; + this.listAttributes.addLabel = this.addLabel; + this.listAttributes.removeLabel = this.removeLabel; + this.listAttributes.addClass = this.addClass; + this.listAttributes.removeClass = this.removeClass; + this.listAttributes.addItem = () => { this.insertWidget(); this.planRender(); }; - this.listAttributes['removeItem'] = index => { + this.listAttributes.removeItem = index => { this.element .querySelector(`[data-index="${this.name + index}"]`) .remove(); @@ -90,7 +90,7 @@ const MultipleFormMixin = { populate() { if (!this.resource || !this.resource['ldp:contains']) return; - this.listAttributes['children'] = []; // reset list + this.listAttributes.children = []; // reset list // set value in form for (const resource of this.resource['ldp:contains']) { @@ -113,10 +113,10 @@ const MultipleFormMixin = { widget.toggleAttribute(name, attributes[name]); else widget.setAttribute(name, attributes[name]); } - this.listAttributes['children'].push(widget); + this.listAttributes.children.push(widget); }, empty() { - this.listAttributes['children'] = []; + this.listAttributes.children = []; this.planRender(); }, getValue() { diff --git a/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts b/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts index e0505c0d..4e2a816e 100644 --- a/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts +++ b/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts @@ -10,8 +10,8 @@ const MultipleselectFormMixin = { type: String, default: '', callback: function (value) { - if (value && value !== this.listAttributes['range']) - this.listAttributes['range'] = value; + if (value && value !== this.listAttributes.range) + this.listAttributes.range = value; }, }, enum: { @@ -19,8 +19,8 @@ const MultipleselectFormMixin = { type: String, default: '', callback: function (value) { - if (value && value !== this.listAttributes['enum']) - this.listAttributes['enum'] = value; + if (value && value !== this.listAttributes.enum) + this.listAttributes.enum = value; }, }, orderAsc: { @@ -79,10 +79,10 @@ const MultipleselectFormMixin = { }, setValue(values: string[]) { // set the values to the dropdown - this.listAttributes['values'] = JSON.stringify(values.map(r => r['@id'])); + this.listAttributes.values = JSON.stringify(values.map(r => r['@id'])); }, empty() { - this.listAttributes['values'] = []; + this.listAttributes.values = []; this.planRender(); }, get type() { diff --git a/src/new-widgets/templatesDependencies/rangeMixin.ts b/src/new-widgets/templatesDependencies/rangeMixin.ts index 0133e8b5..efcc638c 100644 --- a/src/new-widgets/templatesDependencies/rangeMixin.ts +++ b/src/new-widgets/templatesDependencies/rangeMixin.ts @@ -59,8 +59,8 @@ const RangeMixin = { }, created() { this.listPostProcessors = new PostProcessorRegistry(); - this.listAttributes['optionLabel'] = this.optionLabel; - this.listAttributes['optionValue'] = this.optionValue; + this.listAttributes.optionLabel = this.optionLabel; + this.listAttributes.optionValue = this.optionValue; }, async populate() { const resources = this.resource ? this.resource['ldp:contains'] : []; @@ -100,7 +100,7 @@ const RangeMixin = { return { value, label, selectedValue }; }; - this.listAttributes['range'] = await Promise.all( + this.listAttributes.range = await Promise.all( resources.filter(el => el !== null).map(r => getRangeValue(r)), ); } @@ -108,7 +108,7 @@ const RangeMixin = { this.planRender(); }, empty() { - this.listAttributes['range'] = []; + this.listAttributes.range = []; this.planRender(); }, get type() { diff --git a/src/new-widgets/valueTransformationMixins/dateMixin.ts b/src/new-widgets/valueTransformationMixins/dateMixin.ts index ce9b9118..1fd1b4b5 100644 --- a/src/new-widgets/valueTransformationMixins/dateMixin.ts +++ b/src/new-widgets/valueTransformationMixins/dateMixin.ts @@ -14,10 +14,10 @@ const DateMixin = { ) { try { // workaround for giving a specific-formatted value to the form widget - this.listAttributes['originalValue'] = this.formatDateForInput(value); + this.listAttributes.originalValue = this.formatDateForInput(value); } catch (e) { console.warn('Invalid date format for widget', this.name); - this.listAttributes['originalValue'] = ''; + this.listAttributes.originalValue = ''; } const newValue = value ? new Date(value).toLocaleDateString() : value; diff --git a/src/widgets/baseWidget.ts b/src/widgets/baseWidget.ts index 87d2020a..81141cfa 100644 --- a/src/widgets/baseWidget.ts +++ b/src/widgets/baseWidget.ts @@ -103,16 +103,16 @@ export class BaseWidget extends HTMLElement { this.render(); } - get ['each-label'](): string { + get 'each-label'(): string { return this.getAttribute('each-label') || ''; } - set ['each-label'](label: string) { + set 'each-label'(label: string) { this.setAttribute('each-label', label); } - set ['add-label'](label: string) { + set 'add-label'(label: string) { this.setAttribute('add-label', label); } - set ['remove-label'](label: string) { + set 'remove-label'(label: string) { this.setAttribute('remove-label', label); } get dataHolder(): Element[] | null { -- GitLab From dd365533899de75c0ef761a9c55856314909f8b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 22 Nov 2024 00:09:15 +0100 Subject: [PATCH 41/66] fix `lint/complexity/noForEach` --- biome.jsonc | 1 - cypress/e2e/e2e/helpers.cy.ts | 2 +- cypress/e2e/e2e/sib-register.cy.ts | 5 +- cypress/e2e/unit/Compositor.cy.ts | 16 ++-- examples/filtered.html | 21 ++--- src/components/solid-form-search.ts | 8 +- src/components/solid-form.ts | 28 ++++--- src/libs/ComponentFactory.ts | 26 +++---- src/libs/Compositor.ts | 77 ++++++++----------- src/libs/PostProcessorRegistry.ts | 18 ++--- src/libs/store/store.ts | 4 +- src/mixins/filterMixin.ts | 4 +- src/mixins/widgetMixin.ts | 2 +- .../templatesDependencies/rangeMixin.ts | 4 +- src/widgets/baseWidget.ts | 8 +- 15 files changed, 103 insertions(+), 121 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index d10fc219..37a43f72 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -26,7 +26,6 @@ "useTemplate": "off" }, "complexity": { - "noForEach": "off", "noBannedTypes": "off", "useOptionalChain": "off", "noStaticOnlyClass": "off" diff --git a/cypress/e2e/e2e/helpers.cy.ts b/cypress/e2e/e2e/helpers.cy.ts index 4ae799a1..70838e8a 100644 --- a/cypress/e2e/e2e/helpers.cy.ts +++ b/cypress/e2e/e2e/helpers.cy.ts @@ -11,7 +11,7 @@ describe('helpers', function () { doc = win.document; ///@ts-ignore helpers = win.helpers; - doc.querySelectorAll('script').forEach(script => script.remove()); + for (const script of doc.querySelectorAll('script')) script.remove(); }); }); diff --git a/cypress/e2e/e2e/sib-register.cy.ts b/cypress/e2e/e2e/sib-register.cy.ts index d5d82dad..3f08ab8e 100644 --- a/cypress/e2e/e2e/sib-register.cy.ts +++ b/cypress/e2e/e2e/sib-register.cy.ts @@ -11,9 +11,8 @@ describe('Component factory', function () { cnsl = (win as Window & typeof globalThis).console; ///@ts-ignore Sib = win.Sib; - win.document - .querySelectorAll('script') - .forEach(script => script.remove()); + for (const script of win.document.querySelectorAll('script')) + script.remove(); }); }); diff --git a/cypress/e2e/unit/Compositor.cy.ts b/cypress/e2e/unit/Compositor.cy.ts index f31b3423..29254a24 100644 --- a/cypress/e2e/unit/Compositor.cy.ts +++ b/cypress/e2e/unit/Compositor.cy.ts @@ -133,11 +133,11 @@ describe('Mixin Compositor', () => { const hookNames = Reflect.ownKeys(result); expect(hookNames.length).eq(3); - hookNames.forEach(hookName => { - result[hookName].forEach(hook => { + for (const hookName of hookNames) { + for (const hook of result[hookName]) { expect(typeof hook).eq('function'); - }); - }); + } + } expect(result.created.length).eq(3); expect(result.attached.length).eq(2); @@ -157,10 +157,10 @@ describe('Mixin Compositor', () => { const accessors = Object.keys(result); expect(accessors.length).eq(1); - accessors.forEach(accessorName => { + for (const accessorName of accessors) { expect(typeof result[accessorName].get).eq('function'); expect(typeof result[accessorName].set).eq('function'); - }); + } expect(result.accessorTest.get.toString()).eq( Reflect.getOwnPropertyDescriptor( @@ -185,9 +185,9 @@ describe('Mixin Compositor', () => { const methodNames = Array.from(result.keys()); expect(methodNames.length).eq(4); - methodNames.forEach(methodName => { + for (const methodName of methodNames) { expect(typeof result.get(methodName)).eq('function'); - }); + } expect(result.get('methodA').toString()).eq( MixinTestOne.methodA.toString(), diff --git a/examples/filtered.html b/examples/filtered.html index 6b7a8922..cd3f1886 100644 --- a/examples/filtered.html +++ b/examples/filtered.html @@ -29,16 +29,17 @@ function change(input) { if (!(input instanceof HTMLInputElement)) return; const value = input.value; - const elm = input.closest('form').nextElementSibling; + const elm = input.closest("form").nextElementSibling; elm.component.filteredBy = value; } - document.addEventListener('DOMContentLoaded', () => { - document.querySelector('main').addEventListener('change', ({ target }) => - change(target), - ); - [...document.querySelectorAll('input[type=radio]')] - .filter((elm) => elm.checked) - .forEach(change); + document.addEventListener("DOMContentLoaded", () => { + document + .querySelector("main") + .addEventListener("change", ({ target }) => change(target)); + for (const input of document.querySelectorAll("input[type=radio]")) { + if (!input.checked) continue; + change(input); + } }); </script> </head> @@ -61,7 +62,7 @@ <div> <h3>solid-display 1</h3> <form> - filteredBy: + filteredBy: <label ><input type="radio" name="filterBy" value="filter1" checked /> filter1</label @@ -80,7 +81,7 @@ <div> <h3>solid-display 2</h3> <form> - filteredBy: + filteredBy: <label ><input type="radio" name="filterBy" value="filter1" checked /> filter1</label diff --git a/src/components/solid-form-search.ts b/src/components/solid-form-search.ts index 223e26be..c7a954e4 100644 --- a/src/components/solid-form-search.ts +++ b/src/components/solid-form-search.ts @@ -65,10 +65,10 @@ export const SolidFormSearch = { get value(): SearchQuery { const values: SearchQuery = {}; - this.widgets.forEach(widget => { - if (widget == null) return; + for (const widget of this.widgets) { + if (widget == null) continue; const name = (widget.component || widget).name; - if (name == null) return; + if (name == null) continue; let value = widget.component ? widget.component.getValue() : widget.value; try { value = JSON.parse(value); @@ -79,7 +79,7 @@ export const SolidFormSearch = { value: value, }; values[name] = value; - }); + } return values; }, getWidget(field: string, isSet = false): WidgetInterface { diff --git a/src/components/solid-form.ts b/src/components/solid-form.ts index 285c3711..e6470962 100644 --- a/src/components/solid-form.ts +++ b/src/components/solid-form.ts @@ -58,15 +58,15 @@ export const SolidForm = { }, get value(): object { const values = {}; - this.widgets.forEach(widget => { + for (const widget of this.widgets) { const name = (widget.component || widget).name; - if (name == null) return; + if (name == null) continue; let value = widget.component ? widget.component.getValue() : widget.value; try { value = JSON.parse(value); } catch (e) {} setDeepProperty(values, name.split('.'), value); - }); + } // add @id if edition if (this.resource && !this.resource.isContainer?.()) values['@id'] = this.resourceId; @@ -196,7 +196,7 @@ export const SolidForm = { this.submitForm(); // if autosave, submitForm }, displayErrorMessage(errors: [string, any][], errorFullName = '') { - errors.forEach((member: [string, any]) => { + for (const member of errors) { const errorNextName: string = Object.values(member)[0]; const subErrorName = errorFullName === '' @@ -216,22 +216,19 @@ export const SolidForm = { formField.classList.add('error'); const errorParagraph = document.createElement('p'); if (Array.isArray(Object.values(member)[1]) === true) { - Object.values(member)[1].forEach(error => { + for (const error of Object.values(member)[1]) { const errorText = document.createElement('p'); errorText.textContent = error; errorParagraph.appendChild(errorText); - }); + } } else if (typeof Object.values(member)[1] === 'object') { - // @ts-ignore - for (const [key, value] of Object.entries( - Object.values(member)[1], - )) { + for (const value of Object.values(Object.values(member)[1])) { if (Array.isArray(value)) { - value.forEach(error => { + for (const error of value) { const errorText = document.createElement('p'); errorText.textContent = error; errorParagraph.appendChild(errorText); - }); + } } else if (typeof value === 'string') { const errorText = document.createElement('p'); errorText.textContent = value; @@ -251,7 +248,7 @@ export const SolidForm = { const subErrors = Object.entries(objectErrors); this.displayErrorMessage(subErrors, subErrorName); } - }); + } }, empty(): void {}, showError(e: object) { @@ -267,11 +264,12 @@ export const SolidForm = { }, hideError() { const formErrors = this.element.querySelectorAll('.error-message'); - if (formErrors) formErrors.forEach(error => error.remove()); + if (formErrors) for (const error of formErrors) error.remove(); const errorFields = this.element.querySelectorAll('.error'); if (errorFields) - errorFields.forEach(errorField => errorField.classList.remove('error')); + for (const errorField of errorFields) + errorField.classList.remove('error'); const parentElement = this.element.querySelector('[data-id=error]'); if (parentElement) render('', parentElement); diff --git a/src/libs/ComponentFactory.ts b/src/libs/ComponentFactory.ts index b94f300a..87a5cc70 100644 --- a/src/libs/ComponentFactory.ts +++ b/src/libs/ComponentFactory.ts @@ -50,13 +50,13 @@ export class ComponentFactory { initialState: object | undefined, ): any { if (initialState) { - Reflect.ownKeys(initialState).forEach(key => { + for (const key of Reflect.ownKeys(initialState)) { Reflect.defineProperty(componentConstructor.prototype, key, { enumerable: true, writable: true, value: initialState[key], }); - }); + } } return componentConstructor; @@ -72,7 +72,7 @@ export class ComponentFactory { ); const attributesCallback = {}; - attributesList.forEach(key => { + for (const key of attributesList) { const { default: def, type, required, callback } = attributes[key]; let fromType: (value: string) => unknown; @@ -135,7 +135,7 @@ export class ComponentFactory { if (callback && typeof callback === 'function') { attributesCallback[key] = callback; } - }); + } Reflect.defineProperty(componentConstructor, 'observedAttributes', { get: () => @@ -173,7 +173,7 @@ export class ComponentFactory { accessors: AccessorStaticInterface, ): ComponentConstructorInterface { if (accessors) { - Object.keys(accessors).forEach(property => { + for (const property of Object.keys(accessors)) { Reflect.defineProperty(componentConstructor.prototype, property, { get: function () { return Reflect.apply(accessors[property].get, this, []); @@ -182,7 +182,7 @@ export class ComponentFactory { return Reflect.apply(accessors[property].set, this, [value]); }, }); - }); + } } return componentConstructor; } @@ -191,7 +191,7 @@ export class ComponentFactory { componentConstructor: ComponentConstructorInterface, methods: Map<string, Function>, ): ComponentConstructorInterface { - methods.forEach((method, methodName: string) => { + methods.forEach((method, methodName) => { Reflect.defineProperty(componentConstructor.prototype, methodName, { value: function (...args) { return Reflect.apply(method, this, args); @@ -207,25 +207,25 @@ export class ComponentFactory { ): ComponentConstructorInterface { Reflect.defineProperty(componentConstructor.prototype, 'created', { value: function () { - hooks.created.forEach(hook => { + for (const hook of hooks.created) { Reflect.apply(hook, this, []); - }); + } }, }); Reflect.defineProperty(componentConstructor.prototype, 'attached', { value: function () { - hooks.attached.forEach(hook => { + for (const hook of hooks.attached) { Reflect.apply(hook, this, []); - }); + } }, }); Reflect.defineProperty(componentConstructor.prototype, 'detached', { value: function () { - hooks.detached.forEach(hook => { + for (const hook of hooks.detached) { Reflect.apply(hook, this, []); - }); + } }, }); return componentConstructor; diff --git a/src/libs/Compositor.ts b/src/libs/Compositor.ts index a0a8dbc4..dcb21972 100644 --- a/src/libs/Compositor.ts +++ b/src/libs/Compositor.ts @@ -33,14 +33,14 @@ export class Compositor { ) { const { use: currentMixins } = currentMixin; if (currentMixins) { - currentMixins.forEach(mix => { + for (const mix of currentMixins) { if (!mixinAccumulator.has(mix)) { mixinAccumulator.set(mix, mix); deepMergeMixin(mixinAccumulator, mix); } else { console.warn(`Duplicate mixin import (${mix.name})`); } - }); + } } } @@ -55,11 +55,11 @@ export class Compositor { ): AttributesDefinitionInterface { let attributes = {}; - mixins.forEach(mixin => { + for (const mixin of mixins) { if (mixin.attributes) { attributes = { ...mixin.attributes, ...attributes }; } - }); + } return attributes; } @@ -67,11 +67,11 @@ export class Compositor { public static mergeInitialState(mixins: MixinStaticInterface[]): any { let initialState = {}; - mixins.forEach(mixin => { + for (const mixin of mixins) { if (mixin.initialState) { initialState = { ...mixin.initialState, ...initialState }; } - }); + } return initialState; } @@ -84,13 +84,13 @@ export class Compositor { attached: [], detached: [], }; - mixins.reverse().forEach(mixin => { - HOOKS.forEach(hookName => { + for (const mixin of mixins.reverse()) { + for (const hookName of HOOKS) { if (!!mixin[hookName] && typeof mixin[hookName] === 'function') { hooks[hookName].push(mixin[hookName]); } - }); - }); + } + } return hooks; } @@ -98,20 +98,16 @@ export class Compositor { public static mergeMethods(mixins: MixinStaticInterface[]): Map<any, any> { const methods = new Map(); - mixins.reverse().forEach(mixin => { - const keys = Reflect.ownKeys(mixin).filter( - key => - typeof key === 'string' && - API.indexOf(key) < 0 && - !Object.getOwnPropertyDescriptor(mixin, key)!.get && - !Object.getOwnPropertyDescriptor(mixin, key)!.set && - typeof mixin[key] === 'function', - ); - - keys.forEach(key => { + for (const mixin of mixins.reverse()) { + for (const key of Reflect.ownKeys(mixin)) { + if (typeof key !== 'string') continue; + if (API.includes(key)) continue; + const descriptor = Object.getOwnPropertyDescriptor(mixin, key); + if (descriptor?.get || descriptor?.set) continue; + if (typeof mixin[key] !== 'function') continue; methods.set(key, mixin[key]); - }); - }); + } + } return methods; } @@ -119,29 +115,18 @@ export class Compositor { mixins: MixinStaticInterface[], ): AccessorStaticInterface { const accessors = {}; - mixins.reverse().forEach(mixin => { - Reflect.ownKeys(mixin) - .filter( - key => - typeof key === 'string' && - API.indexOf(key) < 0 && - (Object.getOwnPropertyDescriptor(mixin, key)!.get || - Object.getOwnPropertyDescriptor(mixin, key)!.set), - ) - .forEach(prop => { - accessors[prop] = { ...accessors[prop] }; - if (Reflect.getOwnPropertyDescriptor(mixin, prop)!.get) - accessors[prop].get = Reflect.getOwnPropertyDescriptor( - mixin, - prop, - )!.get; - if (Reflect.getOwnPropertyDescriptor(mixin, prop)!.set) - accessors[prop].set = Reflect.getOwnPropertyDescriptor( - mixin, - prop, - )!.set; - }); - }); + for (const mixin of mixins.reverse()) { + for (const prop of Reflect.ownKeys(mixin)) { + if (typeof prop !== 'string') continue; + if (API.includes(prop)) continue; + const descriptor = Object.getOwnPropertyDescriptor(mixin, prop); + if (!descriptor) continue; + if (!descriptor.get && !descriptor.set) continue; + accessors[prop] = { ...accessors[prop] }; + if (descriptor.get) accessors[prop].get = descriptor.get; + if (descriptor.set) accessors[prop].set = descriptor.set; + } + } return accessors; } } diff --git a/src/libs/PostProcessorRegistry.ts b/src/libs/PostProcessorRegistry.ts index bac22efa..13647da8 100644 --- a/src/libs/PostProcessorRegistry.ts +++ b/src/libs/PostProcessorRegistry.ts @@ -23,9 +23,9 @@ export class PostProcessorRegistry { console.log('No post-processors registered.'); } else { console.log('Registered post-processors:'); - this.currentPostProcessors.forEach(proc => { - console.log(`- ${proc.name}`); - }); + for (const postProcessor of this.currentPostProcessors) { + console.log(`- ${postProcessor.name}`); + } } } @@ -34,9 +34,9 @@ export class PostProcessorRegistry { return 'No post-processors registered.'; } else { let formattedText = 'Registered post-processors:\n'; - this.currentPostProcessors.forEach(proc => { - formattedText += `- ${proc.name}\n`; - }); + for (const postProcessor of this.currentPostProcessors) { + formattedText += `- ${postProcessor.name}\n`; + } return formattedText.trim(); } } @@ -48,9 +48,9 @@ export class PostProcessorRegistry { return 'No post-processors registered.'; } else { let formattedText = 'Registered post-processors:\n'; - currentPostProcessors.forEach(proc => { - formattedText += `- ${proc.name}\n`; - }); + for (const postProcessor of currentPostProcessors) { + formattedText += `- ${postProcessor.name}\n`; + } return formattedText.trim(); } } diff --git a/src/libs/store/store.ts b/src/libs/store/store.ts index 8a9871b7..552b88c4 100644 --- a/src/libs/store/store.ts +++ b/src/libs/store/store.ts @@ -478,10 +478,10 @@ class Store { // For federation, clear each source const resource = this.cache.get(id); if (resource['@type'] === 'ldp:Container') { - resource['ldp:contains'].forEach((child: object) => { + for (const child of resource['ldp:contains']) { if (child && child['@type'] === 'ldp:Container') this.cache.delete(child['@id']); - }); + } } this.cache.delete(id); diff --git a/src/mixins/filterMixin.ts b/src/mixins/filterMixin.ts index a71b9201..5cfab947 100644 --- a/src/mixins/filterMixin.ts +++ b/src/mixins/filterMixin.ts @@ -177,9 +177,9 @@ const FilterMixin = { value: attr.value, })); - searchAttributes.forEach(({ name, value }) => { + for (const { name, value } of searchAttributes) { this.searchForm.setAttribute(name, value); - }); + } this.element.insertBefore(this.searchForm, this.element.firstChild); await this.searchForm.component.populate(); diff --git a/src/mixins/widgetMixin.ts b/src/mixins/widgetMixin.ts index a94efcc8..b0994c1d 100644 --- a/src/mixins/widgetMixin.ts +++ b/src/mixins/widgetMixin.ts @@ -275,7 +275,7 @@ const WidgetMixin = { * @param resource - Resource */ widgetAttributes(field: string, resource: Resource): object { - const attrs = { name: field }; + const attrs: Record<string, string> = { name: field }; if (this.isAlias(field)) field = field.split(' as ')[1]; const escapedField = this.getEscapedField(field); diff --git a/src/new-widgets/templatesDependencies/rangeMixin.ts b/src/new-widgets/templatesDependencies/rangeMixin.ts index efcc638c..7e25cc43 100644 --- a/src/new-widgets/templatesDependencies/rangeMixin.ts +++ b/src/new-widgets/templatesDependencies/rangeMixin.ts @@ -24,7 +24,7 @@ const RangeMixin = { const optional = value.trim().split(','); const list = {}; - optional.forEach(element => { + for (const element of optional) { if (element.includes('=')) { const option = element.trim().split('='); const key = option[1].trim(); @@ -34,7 +34,7 @@ const RangeMixin = { const elem = element.trim(); list[elem] = elem; } - }); + } this.addToAttributes(list, 'enum'); } }, diff --git a/src/widgets/baseWidget.ts b/src/widgets/baseWidget.ts index 81141cfa..aed79095 100644 --- a/src/widgets/baseWidget.ts +++ b/src/widgets/baseWidget.ts @@ -16,9 +16,9 @@ export class BaseWidget extends HTMLElement { this.render(); } disconnectedCallback(): void { - this._subscriptions.forEach(subscription => { + for (const subscription of this._subscriptions.values()) { PubSub.unsubscribe(subscription); - }); + } } async render() { this.innerHTML = await evalTemplateString(this.template, { @@ -284,13 +284,13 @@ export class BaseWidget extends HTMLElement { initChangeEvents(): void { if (this.dataHolder) { const event = new Event('change', { bubbles: true }); - this.dataHolder.forEach(element => { + for (const element of this.dataHolder) { element.addEventListener('change', e => { e.preventDefault(); e.stopPropagation(); this.dispatchEvent(event); }); - }); + } } } save(editableField: HTMLElement, editButton: HTMLButtonElement): void { -- GitLab From 53ca5d1174a1cde7ffb4ea080471f4a7b8a3c1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 22 Nov 2024 00:36:58 +0100 Subject: [PATCH 42/66] fix `lint/style/noUselessElse` --- biome.jsonc | 1 - src/components/solid-member-delete.ts | 2 +- src/components/solid-membership.ts | 5 +- src/components/solid-widget.ts | 5 +- src/libs/PostProcessorRegistry.ts | 25 +++++----- src/libs/filter.ts | 3 +- src/libs/store/custom-getter.ts | 60 +++++++++++------------- src/libs/store/store.ts | 12 ++--- src/logger.ts | 3 +- src/mixins/validationMixin.ts | 67 +++++++++++++-------------- src/mixins/widgetMixin.ts | 3 +- 11 files changed, 85 insertions(+), 101 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index 37a43f72..f7acb57e 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -20,7 +20,6 @@ "rules": { "recommended": true, "style": { - "noUselessElse": "off", "noParameterAssign": "off", "noNonNullAssertion": "off", "useTemplate": "off" diff --git a/src/components/solid-member-delete.ts b/src/components/solid-member-delete.ts index 010e011d..29cd1308 100644 --- a/src/components/solid-member-delete.ts +++ b/src/components/solid-member-delete.ts @@ -100,7 +100,7 @@ export const SolidMemberDelete = { const userSet = this.currentMembers.filter(value => { const userId = value['@id']; if (userId === this.dataTargetSrc) return false; - else return true; + return true; }); const currentRes = { diff --git a/src/components/solid-membership.ts b/src/components/solid-membership.ts index 7acc47fd..fc5d712f 100644 --- a/src/components/solid-membership.ts +++ b/src/components/solid-membership.ts @@ -125,7 +125,7 @@ export const SolidMembership = { const userSet = this.currentMembers.filter(value => { const userId = value['@id']; if (userId === this.userId) return false; - else return true; + return true; }); const currentRes = { @@ -152,9 +152,8 @@ export const SolidMembership = { switchMembership() { if (this.isMember) { return this.leaveGroup(); - } else { - return this.joinGroup(); } + return this.joinGroup(); }, validateModal() { // Send method to validationMixin, used by the dialog modal and performAction method diff --git a/src/components/solid-widget.ts b/src/components/solid-widget.ts index 05168032..1e889c71 100644 --- a/src/components/solid-widget.ts +++ b/src/components/solid-widget.ts @@ -53,9 +53,8 @@ export const SolidWidget = { }, // For form widgets, handle nested solid-form getValueFromElement(element: any) { - if (element.tagName === 'SOLID-FORM') - return element.component.value; // nested solid-form - else if (element.component) return element.component.getValue(); // form widget + if (element.tagName === 'SOLID-FORM') return element.component.value; // nested solid-form + if (element.component) return element.component.getValue(); // form widget return element.value; // input }, updateDOM() { diff --git a/src/libs/PostProcessorRegistry.ts b/src/libs/PostProcessorRegistry.ts index 13647da8..ef855e17 100644 --- a/src/libs/PostProcessorRegistry.ts +++ b/src/libs/PostProcessorRegistry.ts @@ -32,13 +32,12 @@ export class PostProcessorRegistry { public getFormattedCallbacks(): string { if (this.currentPostProcessors.length === 0) { return 'No post-processors registered.'; - } else { - let formattedText = 'Registered post-processors:\n'; - for (const postProcessor of this.currentPostProcessors) { - formattedText += `- ${postProcessor.name}\n`; - } - return formattedText.trim(); } + let formattedText = 'Registered post-processors:\n'; + for (const postProcessor of this.currentPostProcessors) { + formattedText += `- ${postProcessor.name}\n`; + } + return formattedText.trim(); } static printFormattedCallbacks( @@ -46,21 +45,19 @@ export class PostProcessorRegistry { ): string { if (currentPostProcessors.length === 0) { return 'No post-processors registered.'; - } else { - let formattedText = 'Registered post-processors:\n'; - for (const postProcessor of currentPostProcessors) { - formattedText += `- ${postProcessor.name}\n`; - } - return formattedText.trim(); } + let formattedText = 'Registered post-processors:\n'; + for (const postProcessor of currentPostProcessors) { + formattedText += `- ${postProcessor.name}\n`; + } + return formattedText.trim(); } public whichCallbackExecutedNext(): string { if (this.currentPostProcessors.length === 0) { return 'No post-processors registered.'; - } else { - return `Next post-processor to be executed is: ${this.currentPostProcessors[0].name}`; } + return `Next post-processor to be executed is: ${this.currentPostProcessors[0].name}`; } public deepCopy(): PostProcessorRegistry { diff --git a/src/libs/filter.ts b/src/libs/filter.ts index 81589b39..3df5145e 100644 --- a/src/libs/filter.ts +++ b/src/libs/filter.ts @@ -101,7 +101,8 @@ const matchValue = async ( if (ret) return orThrow(throwOn, true); } return orThrow(throwOn, await ret); - } else if (Array.isArray(subject)) { + } + if (Array.isArray(subject)) { let ret: any = Promise.resolve(query.value === ''); // if no query, return a match for (const value of subject) { ret = (await ret) || (await matchValue(value, query)); // do not throw here, we need the result diff --git a/src/libs/store/custom-getter.ts b/src/libs/store/custom-getter.ts index 4352022a..fb7ef068 100644 --- a/src/libs/store/custom-getter.ts +++ b/src/libs/store/custom-getter.ts @@ -141,29 +141,22 @@ export class CustomGetter { * @returns */ getLiteralValue(value: any): string | string[] | null { - if (typeof value === 'object') { - // value object: https://www.w3.org/TR/json-ld11/#value-objects - if (value['@value']) { - // 1 language - return value['@value']; - } else if (Array.isArray(value)) { - if (value.length === 0) return null; - if (Array.isArray(value[0])) { - // multiple languages - const ln = store._getLanguage(); - let translatedValue = value.find( - v => v['@language'] && v['@language'] === ln, - ); // find current language - if (!translatedValue) - translatedValue = value.find( - v => v['@language'] && v['@language'] === 'en', - ); // default to en - return translatedValue ? translatedValue['@value'] || null : null; // return value when no translated value is found - } - return value; - } - } - return value; // simple value + if (typeof value !== 'object') return value; + // value object: https://www.w3.org/TR/json-ld11/#value-objects + if (value['@value']) return value['@value']; // 1 language + if (!Array.isArray(value)) return value; + if (value.length === 0) return null; + if (!Array.isArray(value[0])) return value; + // multiple languages + const ln = store._getLanguage(); + let translatedValue = value.find( + v => v['@language'] && v['@language'] === ln, + ); // find current language + if (!translatedValue) + translatedValue = value.find( + v => v['@language'] && v['@language'] === 'en', + ); // default to en + return translatedValue?.['@value'] ?? null; // return value when no translated value is found } /** @@ -193,15 +186,14 @@ export class CustomGetter { this.resource['@type'].includes(type), ); return this.containerTypes.includes(this.resource['@type']); - } else if (this.resource.type) { - if (Array.isArray(this.resource.type)) - return this.containerTypes.some(type => - this.resource.type.includes(type), - ); - return this.containerTypes.includes(this.resource.type); } + if (!this.resource.type) return false; - return false; + if (Array.isArray(this.resource.type)) + return this.containerTypes.some(type => + this.resource.type.includes(type), + ); + return this.containerTypes.includes(this.resource.type); } /** @@ -283,8 +275,8 @@ export class CustomGetter { propertiesKeys.length === 1 && propertiesKeys[0] === this.getExpandedPredicate('permissions') ) - return false; // If only the permissions are present, then the resource is not complete - else if (propertiesKeys.length > 0) return true; + return false; + if (propertiesKeys.length > 0) return true; return false; } @@ -368,8 +360,8 @@ export class CustomGetter { switch (property) { case '@id': if (this.resource['@id']) - return this.getCompactedIri(this.resource['@id']); // Compact @id if possible - else console.log(this.resource, this.resource['@id']); + return this.getCompactedIri(this.resource['@id']); + console.log(this.resource, this.resource['@id']); return; case '@type': return this.resource['@type']; // return synchronously diff --git a/src/libs/store/store.ts b/src/libs/store/store.ts index 552b88c4..0bebf40a 100644 --- a/src/libs/store/store.ts +++ b/src/libs/store/store.ts @@ -179,12 +179,11 @@ class Store { if (this.fetch && authenticated) { // authenticated return this.fetch.then(fn => fn(iri, options)); - } else { - // anonymous - if (options.headers) - options.headers = this._convertHeaders(options.headers); - return fetch(iri, options).then(response => response); } + // anonymous + if (options.headers) + options.headers = this._convertHeaders(options.headers); + return fetch(iri, options).then(response => response); } /** @@ -388,9 +387,8 @@ class Store { ); // notify components }); return response.headers?.get('Location') || null; - } else { - throw response; } + throw response; }); } diff --git a/src/logger.ts b/src/logger.ts index 7925f16b..36fbe72b 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -162,9 +162,8 @@ export class Profiler { private formatTime(time: number): string { if (time >= 1000) { return `${(time / 1000).toFixed(2)} seconds`; - } else { - return `${time.toFixed(2)} ms`; } + return `${time.toFixed(2)} ms`; } private formatComponentStats( diff --git a/src/mixins/validationMixin.ts b/src/mixins/validationMixin.ts index e10fee95..d2d1d732 100644 --- a/src/mixins/validationMixin.ts +++ b/src/mixins/validationMixin.ts @@ -66,40 +66,39 @@ const ValidationMixin = { } }, getModalDialog() { - if (this.confirmationType === 'dialog') { - const quitDialog = () => { - const dialog: any = document.getElementById(this.dialogID); - if (dialog == null) return; - dialog.close(); - }; - const confirmChoice = () => { - this.validateModal(); - quitDialog(); - }; - return html` - <dialog id="${this.dialogID}"> - ${ - this.confirmationWidget - ? preHTML`<${this.confirmationWidget} value=${this.resourceId}></${this.confirmationWidget}>` - : html`<p>${this.confirmationMessage || this.t('validation.message')}</p>` - } - <div> - <button - @click=${confirmChoice} - class=${ifDefined(this.confirmationSubmitClass)} - > - ${this.confirmationSubmitText || this.t('validation.submit-text')} - </button> - <button - @click=${quitDialog} - class=${ifDefined(this.confirmationCancelClass)} - > - ${this.confirmationCancelText || this.t('validation.cancel-text')} - </button> - </div> - </dialog> - `; - } else return ''; + if (this.confirmationType !== 'dialog') return ''; + const quitDialog = () => { + const dialog: any = document.getElementById(this.dialogID); + if (dialog == null) return; + dialog.close(); + }; + const confirmChoice = () => { + this.validateModal(); + quitDialog(); + }; + return html` + <dialog id="${this.dialogID}"> + ${ + this.confirmationWidget + ? preHTML`<${this.confirmationWidget} value=${this.resourceId}></${this.confirmationWidget}>` + : html`<p>${this.confirmationMessage || this.t('validation.message')}</p>` + } + <div> + <button + @click=${confirmChoice} + class=${ifDefined(this.confirmationSubmitClass)} + > + ${this.confirmationSubmitText || this.t('validation.submit-text')} + </button> + <button + @click=${quitDialog} + class=${ifDefined(this.confirmationCancelClass)} + > + ${this.confirmationCancelText || this.t('validation.cancel-text')} + </button> + </div> + </dialog> + `; }, }; diff --git a/src/mixins/widgetMixin.ts b/src/mixins/widgetMixin.ts index b0994c1d..7440d9f6 100644 --- a/src/mixins/widgetMixin.ts +++ b/src/mixins/widgetMixin.ts @@ -169,7 +169,8 @@ const WidgetMixin = { if (Array.isArray(fieldValue) && !fieldValue['ldp:contains']) { return JSON.stringify(fieldValue); // Dumb edge case because if the array bears only one item, when compacted the array translates into one object - } else if ( + } + if ( typeof fieldValue === 'object' && fieldValue['@id'] && 1 === Object.keys(fieldValue).length -- GitLab From ff2ca51f1459440da9a110054dcbfc8f30507d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 22 Nov 2024 01:13:39 +0100 Subject: [PATCH 43/66] fix `lint/style/noNonNullAssertion` --- biome.jsonc | 1 - cypress/e2e/e2e/helpers.cy.ts | 17 +++++++++-------- cypress/e2e/unit/Compositor.cy.ts | 4 ++-- cypress/e2e/unit/store.cy.ts | 2 +- src/components/solid-display.ts | 2 +- src/mixins/widgetMixin.ts | 2 +- .../templatesDependencies/formFileMixin.ts | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index f7acb57e..5e137c16 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -21,7 +21,6 @@ "recommended": true, "style": { "noParameterAssign": "off", - "noNonNullAssertion": "off", "useTemplate": "off" }, "complexity": { diff --git a/cypress/e2e/e2e/helpers.cy.ts b/cypress/e2e/e2e/helpers.cy.ts index 70838e8a..7e1aa85c 100644 --- a/cypress/e2e/e2e/helpers.cy.ts +++ b/cypress/e2e/e2e/helpers.cy.ts @@ -176,22 +176,22 @@ describe('helpers', function () { describe('asyncQuerySelector', () => { it('select an element already in document', async () => { - const list = doc.querySelector('#async-qs ul')!; + const list = doc.querySelector('#async-qs ul'); const list2 = await helpers.asyncQuerySelector('#async-qs ul'); expect(list2).to.equal(list); }); it('select an element already in another element', async () => { - const list = doc.querySelector('#async-qs ul')!; + const list = doc.querySelector('#async-qs ul') as HTMLUListElement; const first1 = list.querySelector<HTMLLIElement>(':scope > :first-child'); const first2 = await helpers.asyncQuerySelector<HTMLLIElement>( ':scope > :first-child', list, ); - expect(first2).to.equal(first1!); + expect(first2).to.equal(first1); }); it('select an element not yet in the DOM', async () => { - const list = doc.querySelector('#async-qs ul')!; + const list = doc.querySelector('#async-qs ul') as HTMLUListElement; const li = doc.createElement('li'); li.classList.add('added'); setTimeout(() => list.append(li)); @@ -199,11 +199,11 @@ describe('helpers', function () { expect(added1).to.be.null; const added2 = await helpers.asyncQuerySelector(':scope > .added', list); const added3 = list.querySelector(':scope > .added'); - expect(added2).to.equal(added3!); + expect(added2).to.equal(added3); }); it('select an element not yet matching selector', async () => { - const list = doc.querySelector('#async-qs ul')!; + const list = doc.querySelector('#async-qs ul') as HTMLUListElement; const li = doc.createElement('li'); list.append(li); setTimeout(() => li.classList.add('classed')); @@ -214,7 +214,7 @@ describe('helpers', function () { list, ); const classed3 = list.querySelector(':scope > .classed'); - expect(classed2).to.equal(classed3!); + expect(classed2).to.equal(classed3); }); it('select an element generated by a solid-display', () => { cy.get('#async-qs').then(async div => { @@ -235,7 +235,8 @@ describe('helpers', function () { describe('asyncQuerySelectorAll', () => { const items: Element[] = []; it('select currents and futures elements in DOM', async () => { - const list = doc.querySelector('#async-qs ol')!; + const list = doc.querySelector('#async-qs ol'); + if (!list) throw new Error('no `#async-qs ol`'); (async () => { for await (const li of helpers.asyncQuerySelectorAll('li', list)) items.push(li); diff --git a/cypress/e2e/unit/Compositor.cy.ts b/cypress/e2e/unit/Compositor.cy.ts index 29254a24..dd50903d 100644 --- a/cypress/e2e/unit/Compositor.cy.ts +++ b/cypress/e2e/unit/Compositor.cy.ts @@ -166,13 +166,13 @@ describe('Mixin Compositor', () => { Reflect.getOwnPropertyDescriptor( component, 'accessorTest', - )!.get!.toString(), + )?.get?.toString(), ); expect(result.accessorTest.set.toString()).eq( Reflect.getOwnPropertyDescriptor( MixinTestOne, 'accessorTest', - )!.set!.toString(), + )?.set?.toString(), ); }); diff --git a/cypress/e2e/unit/store.cy.ts b/cypress/e2e/unit/store.cy.ts index 1084419f..e379d2ca 100644 --- a/cypress/e2e/unit/store.cy.ts +++ b/cypress/e2e/unit/store.cy.ts @@ -59,7 +59,7 @@ describe('store', { testIsolation: false }, function () { }; await store.setLocalData(dataToSave1, url); const dataRead1 = await store.getData(url); - expect(await dataRead1!.foo).eq('bar'); + expect(await dataRead1?.foo).eq('bar'); store.clearCache(url); }); }); diff --git a/src/components/solid-display.ts b/src/components/solid-display.ts index a3abe0c2..71bbb9ff 100644 --- a/src/components/solid-display.ts +++ b/src/components/solid-display.ts @@ -90,7 +90,7 @@ export const SolidDisplay = { }, // Here "even.target" points to the content of the widgets of the children of solid-display dispatchSelect(event: Event, resourceId: string): void { - const linkTarget = (event!.target as Element).closest('a'); + const linkTarget = (event?.target as Element).closest('a'); if (linkTarget && linkTarget.hasAttribute('href')) return; const resource = { '@id': resourceId }; this.element.dispatchEvent( diff --git a/src/mixins/widgetMixin.ts b/src/mixins/widgetMixin.ts index 7440d9f6..2c5d17af 100644 --- a/src/mixins/widgetMixin.ts +++ b/src/mixins/widgetMixin.ts @@ -342,7 +342,7 @@ const WidgetMixin = { attrs, ); - const resourceId = resource ? resource!['@id'] : null; + const resourceId = resource?.['@id'] ?? null; if (this.multiple(escapedField)) attrs.widget = this.getWidget(escapedField).tagName; if (this.getAction(escapedField) && resourceId) diff --git a/src/new-widgets/templatesDependencies/formFileMixin.ts b/src/new-widgets/templatesDependencies/formFileMixin.ts index 515cfc61..5c6a919b 100644 --- a/src/new-widgets/templatesDependencies/formFileMixin.ts +++ b/src/new-widgets/templatesDependencies/formFileMixin.ts @@ -50,13 +50,13 @@ const FormFileMixin = { } const filePicker = this.element.querySelector('input[type="file"]'); - if (filePicker.files!.length < 1) return; + if (filePicker.files?.length < 1) return; const dataHolder = this.element.querySelector('input[data-holder]'); this.listAttributes.output = 'â³'; this.planRender(); - const file = filePicker.files![0]; + const file = filePicker.files?.[0]; const formData = new FormData(); formData.append('file', file); store -- GitLab From b61ce1899fdc5c4d42e6a5f65b40c557edf89597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 22 Nov 2024 14:10:33 +0100 Subject: [PATCH 44/66] fix `lint/complexity/noStaticOnlyClass` --- biome.jsonc | 3 +-- src/libs/ComponentFactory.ts | 35 ++++++++++++---------------- src/libs/Compositor.ts | 44 +++++++++++++----------------------- src/libs/Sib.ts | 15 +++++------- 4 files changed, 37 insertions(+), 60 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index 5e137c16..0e841887 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -25,8 +25,7 @@ }, "complexity": { "noBannedTypes": "off", - "useOptionalChain": "off", - "noStaticOnlyClass": "off" + "useOptionalChain": "off" }, "suspicious": { "noExplicitAny": "off", diff --git a/src/libs/ComponentFactory.ts b/src/libs/ComponentFactory.ts index 87a5cc70..290a7ebd 100644 --- a/src/libs/ComponentFactory.ts +++ b/src/libs/ComponentFactory.ts @@ -8,10 +8,8 @@ import type { MixinStaticInterface, } from './interfaces'; -export class ComponentFactory { - public static build( - component: MixinStaticInterface, - ): ComponentConstructorInterface { +export const ComponentFactory = { + build(component: MixinStaticInterface): ComponentConstructorInterface { const { initialState, attributes, methods, hooks, accessors, name } = Compositor.merge(component, Compositor.mergeMixin(component)); @@ -43,9 +41,8 @@ export class ComponentFactory { }); return componentConstructor; - } - - protected static bindInitialState( + }, + bindInitialState( componentConstructor: ComponentConstructorInterface, initialState: object | undefined, ): any { @@ -60,9 +57,8 @@ export class ComponentFactory { } return componentConstructor; - } - - protected static bindAttributes( + }, + bindAttributes( componentConstructor: ComponentConstructorInterface, attributes: AttributesDefinitionInterface | undefined, ): ComponentConstructorInterface { @@ -166,9 +162,8 @@ export class ComponentFactory { ); } return componentConstructor; - } - - protected static bindAccessors( + }, + bindAccessors( componentConstructor: ComponentConstructorInterface, accessors: AccessorStaticInterface, ): ComponentConstructorInterface { @@ -185,9 +180,8 @@ export class ComponentFactory { } } return componentConstructor; - } - - protected static bindMethods( + }, + bindMethods( componentConstructor: ComponentConstructorInterface, methods: Map<string, Function>, ): ComponentConstructorInterface { @@ -199,9 +193,8 @@ export class ComponentFactory { }); }); return componentConstructor; - } - - protected static bindHooks( + }, + bindHooks( componentConstructor: ComponentConstructorInterface, hooks: ArrayOfHooksInterface, ): ComponentConstructorInterface { @@ -229,5 +222,5 @@ export class ComponentFactory { }, }); return componentConstructor; - } -} + }, +}; diff --git a/src/libs/Compositor.ts b/src/libs/Compositor.ts index dcb21972..3d7d5ead 100644 --- a/src/libs/Compositor.ts +++ b/src/libs/Compositor.ts @@ -9,8 +9,8 @@ import type { const HOOKS = ['created', 'attached', 'detached']; const API = ['name', 'use', 'attributes', 'initialState', ...HOOKS]; -export class Compositor { - public static merge( +export const Compositor = { + merge( component: MixinStaticInterface, mixins: MixinStaticInterface[], ): ComponentStaticInterface { @@ -22,11 +22,8 @@ export class Compositor { accessors: Compositor.mergeAccessors([component, ...mixins]), hooks: Compositor.mergeHooks([component, ...mixins]), }; - } - - public static mergeMixin( - component: MixinStaticInterface, - ): MixinStaticInterface[] { + }, + mergeMixin(component: MixinStaticInterface): MixinStaticInterface[] { function deepMergeMixin( mixinAccumulator: Map<MixinStaticInterface, MixinStaticInterface>, currentMixin: MixinStaticInterface, @@ -48,9 +45,8 @@ export class Compositor { deepMergeMixin(mixins, component); return Array.from(mixins.values()); - } - - public static mergeAttributes( + }, + mergeAttributes( mixins: MixinStaticInterface[], ): AttributesDefinitionInterface { let attributes = {}; @@ -62,9 +58,8 @@ export class Compositor { } return attributes; - } - - public static mergeInitialState(mixins: MixinStaticInterface[]): any { + }, + mergeInitialState(mixins: MixinStaticInterface[]): any { let initialState = {}; for (const mixin of mixins) { @@ -74,11 +69,8 @@ export class Compositor { } return initialState; - } - - public static mergeHooks( - mixins: MixinStaticInterface[], - ): ArrayOfHooksInterface { + }, + mergeHooks(mixins: MixinStaticInterface[]): ArrayOfHooksInterface { const hooks = { created: [], attached: [], @@ -93,9 +85,8 @@ export class Compositor { } return hooks; - } - - public static mergeMethods(mixins: MixinStaticInterface[]): Map<any, any> { + }, + mergeMethods(mixins: MixinStaticInterface[]): Map<any, any> { const methods = new Map(); for (const mixin of mixins.reverse()) { @@ -109,11 +100,8 @@ export class Compositor { } } return methods; - } - - public static mergeAccessors( - mixins: MixinStaticInterface[], - ): AccessorStaticInterface { + }, + mergeAccessors(mixins: MixinStaticInterface[]): AccessorStaticInterface { const accessors = {}; for (const mixin of mixins.reverse()) { for (const prop of Reflect.ownKeys(mixin)) { @@ -128,5 +116,5 @@ export class Compositor { } } return accessors; - } -} + }, +}; diff --git a/src/libs/Sib.ts b/src/libs/Sib.ts index 42b97e67..036fc9e6 100644 --- a/src/libs/Sib.ts +++ b/src/libs/Sib.ts @@ -6,16 +6,13 @@ import type { MixinStaticInterface, } from './interfaces.js'; -export class Sib { - public static register(componentDefinition: MixinStaticInterface): void { +export const Sib = { + register(componentDefinition: MixinStaticInterface): void { const component = ComponentFactory.build(componentDefinition); const cls = Sib.toElement(component); defineComponent(component.name, cls); - } - - protected static toElement( - component: ComponentConstructorInterface, - ): typeof HTMLElement { + }, + toElement(component: ComponentConstructorInterface): typeof HTMLElement { return class extends HTMLElement { private _component: ComponentInterface | null = null; @@ -55,5 +52,5 @@ export class Sib { this.component.detached(); } }; - } -} + }, +}; -- GitLab From e52701a85a9877c336d36fea6a187213b143c88f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 22 Nov 2024 14:11:10 +0100 Subject: [PATCH 45/66] fix `lint/complexity/useOptionalChain` --- biome.jsonc | 3 +-- src/components/solid-display.ts | 2 +- src/components/solid-form.ts | 2 +- src/libs/lit-helpers.ts | 2 +- src/libs/store/store.ts | 3 +-- src/mixins/attributeBinderMixin.ts | 9 ++++----- src/mixins/sorterMixin.ts | 3 +-- src/mixins/widgetMixin.ts | 4 ++-- src/widgets/baseWidget.ts | 8 ++------ 9 files changed, 14 insertions(+), 22 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index 0e841887..01c0a42d 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -24,8 +24,7 @@ "useTemplate": "off" }, "complexity": { - "noBannedTypes": "off", - "useOptionalChain": "off" + "noBannedTypes": "off" }, "suspicious": { "noExplicitAny": "off", diff --git a/src/components/solid-display.ts b/src/components/solid-display.ts index 71bbb9ff..24564766 100644 --- a/src/components/solid-display.ts +++ b/src/components/solid-display.ts @@ -91,7 +91,7 @@ export const SolidDisplay = { // Here "even.target" points to the content of the widgets of the children of solid-display dispatchSelect(event: Event, resourceId: string): void { const linkTarget = (event?.target as Element).closest('a'); - if (linkTarget && linkTarget.hasAttribute('href')) return; + if (linkTarget?.hasAttribute('href')) return; const resource = { '@id': resourceId }; this.element.dispatchEvent( new CustomEvent('resourceSelect', { detail: { resource: resource } }), diff --git a/src/components/solid-form.ts b/src/components/solid-form.ts index e6470962..19031c4d 100644 --- a/src/components/solid-form.ts +++ b/src/components/solid-form.ts @@ -96,7 +96,7 @@ export const SolidForm = { } // Nested containers - if (object && object['@id'] && !value[predicate]['@id']) + if (object?.['@id'] && !value[predicate]['@id']) value[predicate]['@id'] = object['@id']; //FIXME: Edge case of array support, ugly management diff --git a/src/libs/lit-helpers.ts b/src/libs/lit-helpers.ts index 01058697..b3d13541 100644 --- a/src/libs/lit-helpers.ts +++ b/src/libs/lit-helpers.ts @@ -73,7 +73,7 @@ class SpreadDirective extends Directive { // Handle event listeners (e.g., @click) if (prefix === '@') { - const prevHandler = prevData && prevData[key]; + const prevHandler = prevData?.[key]; if (!prevHandler || prevHandler !== value) { const name = key.slice(1); // Extract event name if (prevHandler) element.removeEventListener(name, prevHandler); diff --git a/src/libs/store/store.ts b/src/libs/store/store.ts index 0bebf40a..a1921ff8 100644 --- a/src/libs/store/store.ts +++ b/src/libs/store/store.ts @@ -102,8 +102,7 @@ class Store { !this.loadingList.has(key) ) { const resource = this.get(key); - if (resource && resource.isFullResource?.() && !forceFetch) - return resource; // if resource is not complete, re-fetch it + if (resource?.isFullResource?.() && !forceFetch) return resource; // if resource is not complete, re-fetch it } return new Promise(async resolve => { diff --git a/src/mixins/attributeBinderMixin.ts b/src/mixins/attributeBinderMixin.ts index 6e2aec83..0258d782 100644 --- a/src/mixins/attributeBinderMixin.ts +++ b/src/mixins/attributeBinderMixin.ts @@ -54,7 +54,7 @@ const AttributeBinderMixin = { * @returns - object representing attributes of an element with resolved values */ async transformAttributes(attributes: object, resource: Resource) { - const isContainer = resource && resource.isContainer?.(); + const isContainer = resource?.isContainer?.(); for (const attr of Object.keys(attributes)) { const value = attributes[attr]; @@ -78,10 +78,9 @@ const AttributeBinderMixin = { // retry until sibAuth is defined const userId = await this.retry(this.getUser.bind(this)); // TODO: Using this.context makes no sense here. Use same-attribute-context="context-id" instead? - const user = - userId && userId['@id'] - ? await store.getData(userId['@id'], this.context || base_context) - : null; + const user = userId?.['@id'] + ? await store.getData(userId['@id'], this.context || base_context) + : null; if (!user) { attributes[attr] = ''; continue; diff --git a/src/mixins/sorterMixin.ts b/src/mixins/sorterMixin.ts index e01a7b23..35b9b099 100644 --- a/src/mixins/sorterMixin.ts +++ b/src/mixins/sorterMixin.ts @@ -88,8 +88,7 @@ const SorterMixin = { sortingKey = this.sortForm.component.value.field.value; } const orderField = this.sortForm.component.value.order; - orderValueToSort = - orderField && orderField.value ? orderField.value : 'asc'; + orderValueToSort = orderField?.value ? orderField.value : 'asc'; } } // sorting data according to the defined value of sortingKey diff --git a/src/mixins/widgetMixin.ts b/src/mixins/widgetMixin.ts index 2c5d17af..7fc5b005 100644 --- a/src/mixins/widgetMixin.ts +++ b/src/mixins/widgetMixin.ts @@ -55,7 +55,7 @@ const WidgetMixin = { if (attr) return parseFieldsString(attr); let resource = this.resource as Resource; - if (resource && resource.isContainer?.()) { + if (resource?.isContainer?.()) { // If container, keep the 1rst resource for (const res of resource['ldp:contains']) { resource = res; @@ -408,7 +408,7 @@ const WidgetMixin = { } // Subscribe widgets if they show a resource - if (value && value['@id']) attributes['auto-subscribe'] = value['@id']; + if (value?.['@id']) attributes['auto-subscribe'] = value['@id']; // Transform store://XXX attributes if (transformAttributes) diff --git a/src/widgets/baseWidget.ts b/src/widgets/baseWidget.ts index aed79095..9e10d3a4 100644 --- a/src/widgets/baseWidget.ts +++ b/src/widgets/baseWidget.ts @@ -27,7 +27,7 @@ export class BaseWidget extends HTMLElement { label: this.label, placeholder: this.placeholder, value: this.value, - id: (this._value && this._value['@id']) || '', + id: this._value?.['@id'] || '', escapedValue: this.escapedValue, range: await this.htmlRange, multiple: this.multiple, @@ -204,11 +204,7 @@ export class BaseWidget extends HTMLElement { this._listen(element['@id']); let selected: boolean; - if ( - this._value && - this._value.isContainer && - this._value.isContainer() - ) { + if (this._value?.isContainer?.()) { // selected options for multiple select selected = false; for await (const value of this._value['ldp:contains']) { -- GitLab From 0862975b6a7dc2b198ebee844f6df6111afd084c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Thu, 28 Nov 2024 16:16:56 +0100 Subject: [PATCH 46/66] fix `style/useTemplate` --- biome.jsonc | 3 +-- cypress/e2e/unit/ComponentFactory.cy.ts | 2 +- cypress/e2e/unit/Compositor.cy.ts | 2 +- src/components/solid-display.ts | 2 +- src/components/solid-form-search.ts | 12 +++++----- src/components/solid-form.ts | 13 +++++----- src/components/solid-membership.ts | 4 ++-- src/components/solid-table.ts | 4 ++-- src/libs/filter.ts | 4 ++-- src/libs/helpers.ts | 8 +++---- src/mixins/grouperMixin.ts | 2 +- src/mixins/serverPaginationMixin.ts | 8 +++---- src/mixins/widgetMixin.ts | 24 +++++++++---------- .../callbackMixins/richtextMixin.ts | 4 ++-- src/widgets/baseWidget.ts | 2 +- 15 files changed, 46 insertions(+), 48 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index 01c0a42d..914d81e8 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -20,8 +20,7 @@ "rules": { "recommended": true, "style": { - "noParameterAssign": "off", - "useTemplate": "off" + "noParameterAssign": "off" }, "complexity": { "noBannedTypes": "off" diff --git a/cypress/e2e/unit/ComponentFactory.cy.ts b/cypress/e2e/unit/ComponentFactory.cy.ts index fa69a0d9..91fcd91e 100644 --- a/cypress/e2e/unit/ComponentFactory.cy.ts +++ b/cypress/e2e/unit/ComponentFactory.cy.ts @@ -93,7 +93,7 @@ const Component = { message: '', }, get accessorTest() { - return 'hello ' + this.accessorValue; + return `hello ${this.accessorValue}`; }, created() { this.message += '!!'; diff --git a/cypress/e2e/unit/Compositor.cy.ts b/cypress/e2e/unit/Compositor.cy.ts index dd50903d..0706a2f1 100644 --- a/cypress/e2e/unit/Compositor.cy.ts +++ b/cypress/e2e/unit/Compositor.cy.ts @@ -73,7 +73,7 @@ const component = { }, }, get accessorTest() { - return 'hello ' + this.accessorValue; + return `hello ${this.accessorValue}`; }, created() { console.log('created3'); diff --git a/src/components/solid-display.ts b/src/components/solid-display.ts index 24564766..7b3d8f2b 100644 --- a/src/components/solid-display.ts +++ b/src/components/solid-display.ts @@ -63,7 +63,7 @@ export const SolidDisplay = { if (this.resourceId) { this.activeSubscription = PubSub.subscribe( - 'enterRoute.' + this.resourceId, + `enterRoute.${this.resourceId}`, this.addActiveCallback.bind(this), ); } diff --git a/src/components/solid-form-search.ts b/src/components/solid-form-search.ts index c7a954e4..673b0422 100644 --- a/src/components/solid-form-search.ts +++ b/src/components/solid-form-search.ts @@ -86,20 +86,20 @@ export const SolidFormSearch = { let tagName = ''; // If auto-range-[field] exists, create range-[field] and sets its value if ( - this.element.hasAttribute('auto-range-' + field) && - !this.element.hasAttribute('range-' + field) + this.element.hasAttribute(`auto-range-${field}`) && + !this.element.hasAttribute(`range-${field}`) ) { const idField = `${this.rangeId}_${field}`; - this.element.setAttribute('range-' + field, 'store://local.' + idField); + this.element.setAttribute(`range-${field}`, `store://local.${idField}`); this.populate(); } - const widgetAttribute = this.element.getAttribute('widget-' + field); + const widgetAttribute = this.element.getAttribute(`widget-${field}`); // Choose widget if ( !widgetAttribute && - (this.element.hasAttribute('range-' + field) || - this.element.hasAttribute('enum-' + field)) + (this.element.hasAttribute(`range-${field}`) || + this.element.hasAttribute(`enum-${field}`)) ) { tagName = 'solid-form-dropdown'; } else { diff --git a/src/components/solid-form.ts b/src/components/solid-form.ts index 19031c4d..ebbb1389 100644 --- a/src/components/solid-form.ts +++ b/src/components/solid-form.ts @@ -115,15 +115,15 @@ export const SolidForm = { }, getWidget(field: string, isSet = false): WidgetInterface { let tagName = ''; - const widgetAttribute = this.element.getAttribute('widget-' + field); + const widgetAttribute = this.element.getAttribute(`widget-${field}`); // Choose widget - if (!widgetAttribute && this.element.hasAttribute('upload-url-' + field)) { + if (!widgetAttribute && this.element.hasAttribute(`upload-url-${field}`)) { tagName = 'solid-form-file'; } else if ( !widgetAttribute && - (this.element.hasAttribute('range-' + field) || - this.element.hasAttribute('enum-' + field)) + (this.element.hasAttribute(`range-${field}`) || + this.element.hasAttribute(`enum-${field}`)) ) { tagName = 'solid-form-dropdown'; } else { @@ -201,11 +201,10 @@ export const SolidForm = { const subErrorName = errorFullName === '' ? errorNextName - : errorFullName.concat('.' + errorNextName); + : `${errorFullName}.${errorNextName}`; let errorFieldName = ''; - if (errorFullName) - errorFieldName = errorFullName.concat('.' + errorNextName); + if (errorFullName) errorFieldName = `${errorFullName}.${errorNextName}`; else errorFieldName = errorNextName; if (errorFieldName) { diff --git a/src/components/solid-membership.ts b/src/components/solid-membership.ts index fc5d712f..e5691751 100644 --- a/src/components/solid-membership.ts +++ b/src/components/solid-membership.ts @@ -169,7 +169,7 @@ export const SolidMembership = { button = html` <solid-ac-checker data-src="${this.dataSrc}" permission="acl:Read" - class=${ifDefined(`${this.classSubmitButton ? 'leave ' + this.classSubmitButton : 'leave'}`)} + class=${ifDefined(`${this.classSubmitButton ? `leave ${this.classSubmitButton}` : 'leave'}`)} > <button @click=${this.changeMembership.bind(this)}>${this.dataLeaveLabel || this.t('solid-leave-group.button')}</button> ${this.getModalDialog()} @@ -179,7 +179,7 @@ export const SolidMembership = { button = html` <solid-ac-checker data-src="${this.dataSrc}" permission="acl:Read" - class=${ifDefined(`${this.classSubmitButton ? 'join ' + this.classSubmitButton : 'join'}`)} + class=${ifDefined(`${this.classSubmitButton ? `join ${this.classSubmitButton}` : 'join'}`)} > <button @click=${this.changeMembership.bind(this)}>${this.dataJoinLabel || this.t('solid-join-group.button')}</button> ${this.getModalDialog()} diff --git a/src/components/solid-table.ts b/src/components/solid-table.ts index 3946dc05..318d6df6 100644 --- a/src/components/solid-table.ts +++ b/src/components/solid-table.ts @@ -112,7 +112,7 @@ export const SolidTable = { */ async createCellWidget(field: string, resource: Resource) { // if regular widget - if (!this.element.hasAttribute('editable-' + field)) + if (!this.element.hasAttribute(`editable-${field}`)) return this.createWidgetTemplate(field, resource, true); // if editable widget @@ -162,7 +162,7 @@ export const SolidTable = { const template = html` <tr> ${this.selectable !== null ? html`<th><input type="checkbox" @change="${this.selectAll.bind(this)}" /></th>` : ''} - ${fields.map((field: string) => html`<th>${this.element.hasAttribute('label-' + field) ? this.element.getAttribute('label-' + field) : field}</th>`)} + ${fields.map((field: string) => html`<th>${this.element.hasAttribute(`label-${field}`) ? this.element.getAttribute(`label-${field}`) : field}</th>`)} </tr> `; return template; diff --git a/src/libs/filter.ts b/src/libs/filter.ts index 3df5145e..e4a26418 100644 --- a/src/libs/filter.ts +++ b/src/libs/filter.ts @@ -42,7 +42,7 @@ const getSetRegexp = (field: string) => { * @returns true if the field is a special search field */ const isSearchField = (field: string, searchForm: any) => { - return searchForm.hasAttribute('search-' + field); + return searchForm.hasAttribute(`search-${field}`); }; /** * Get the fields targetted by a search field @@ -51,7 +51,7 @@ const isSearchField = (field: string, searchForm: any) => { * @returns a list of fields targetted by the current search field */ const getSearchField = (field: string, searchForm: any): string[] => { - return parseFieldsString(searchForm.getAttribute('search-' + field)); + return parseFieldsString(searchForm.getAttribute(`search-${field}`)); }; /** diff --git a/src/libs/helpers.ts b/src/libs/helpers.ts index b7337e89..103c8159 100644 --- a/src/libs/helpers.ts +++ b/src/libs/helpers.ts @@ -1,7 +1,7 @@ import Fuse from 'fuse.js'; function uniqID(): string { - return '_' + (Math.random() * 36 ** 20).toString(36).slice(0, 10); + return `_${(Math.random() * 36 ** 20).toString(36).slice(0, 10)}`; } function stringToDom(html: string): DocumentFragment { @@ -18,11 +18,11 @@ async function evalTemplateString( const keys = Object.keys(variables); const values = keys.map(key => variables[key]); try { - const func = AsyncFunction.call(null, ...keys, 'return `' + str + '`'); + const func = AsyncFunction.call(null, ...keys, `return \`${str}\``); return await func(...values); } catch (e) { console.log(e); - throw new SyntaxError('`' + str + '`'); + throw new SyntaxError(`\`${str}\``); } } @@ -157,7 +157,7 @@ function parseFieldsString(fields: string): string[] { } function findClosingBracketMatchIndex(str: string, pos: number) { - if (str[pos] !== '(') throw new Error("No '(' at index " + pos); + if (str[pos] !== '(') throw new Error(`No '(' at index ${pos}`); let depth = 1; for (let i = pos + 1; i < str.length; i++) { switch (str[i]) { diff --git a/src/mixins/grouperMixin.ts b/src/mixins/grouperMixin.ts index 5934bb20..10f65337 100644 --- a/src/mixins/grouperMixin.ts +++ b/src/mixins/grouperMixin.ts @@ -67,7 +67,7 @@ const GrouperMixin = { groups[group].resources, // give only resources from group listPostProcessors.deepCopy(), // copy post processors parent, // parent is group widget - context + '_' + group, + `${context}_${group}`, ); } } else { diff --git a/src/mixins/serverPaginationMixin.ts b/src/mixins/serverPaginationMixin.ts index 20de7052..3ac5d898 100644 --- a/src/mixins/serverPaginationMixin.ts +++ b/src/mixins/serverPaginationMixin.ts @@ -38,11 +38,11 @@ const ServerPaginationMixin = { }, getCurrentOffset(resourceId: string, limit: number) { - return this.currentOffset[resourceId + '#p' + limit]; + return this.currentOffset[`${resourceId}#p${limit}`]; }, async setCurrentOffset(resourceId: string, offset: number): Promise<void> { - const index = resourceId + '#p' + this.limit; + const index = `${resourceId}#p${this.limit}`; this.currentOffset[index] = this.offset = offset; this.pageNumber = Number(this.offset / this.limit); this.currentPage[resourceId] = this.pageNumber; @@ -51,7 +51,7 @@ const ServerPaginationMixin = { }, async decreaseCurrentOffset(resourceId: string): Promise<void> { - const index = resourceId + '#p' + this.limit; + const index = `${resourceId}#p${this.limit}`; this.currentOffset[index] = this.offset = this.offset - this.limit; this.currentPage[index] = this.offset / this.limit; this.pageNumber = this.offset / this.limit; @@ -61,7 +61,7 @@ const ServerPaginationMixin = { }, async increaseCurrentOffset(resourceId: string): Promise<void> { - const index = resourceId + '#p' + this.limit; + const index = `${resourceId}#p${this.limit}`; this.currentOffset[index] = this.offset = this.offset + this.limit; this.currentPage[index] = this.offset / this.limit; diff --git a/src/mixins/widgetMixin.ts b/src/mixins/widgetMixin.ts index 7fc5b005..6fb172c7 100644 --- a/src/mixins/widgetMixin.ts +++ b/src/mixins/widgetMixin.ts @@ -87,7 +87,7 @@ const WidgetMixin = { * @param field - string */ getAction(field: string): string { - const action = this.element.getAttribute('action-' + field); + const action = this.element.getAttribute(`action-${field}`); return action; }, /** @@ -95,7 +95,7 @@ const WidgetMixin = { * @param field - string */ editable(field: string): string { - return this.element.hasAttribute('editable-' + field); + return this.element.hasAttribute(`editable-${field}`); }, /** * Return regexp to check if "field" is a set @@ -192,8 +192,8 @@ const WidgetMixin = { return this.getAction(escapedField); } - if (this.element.hasAttribute('value-' + field)) { - return this.element.getAttribute('value-' + field); + if (this.element.hasAttribute(`value-${field}`)) { + return this.element.getAttribute(`value-${field}`); } if (this.isAlias(field)) { @@ -209,8 +209,8 @@ const WidgetMixin = { resourceValue === null ) // If null or empty, return field default value - return this.element.hasAttribute('default-' + field) - ? this.element.getAttribute('default-' + field) + return this.element.hasAttribute(`default-${field}`) + ? this.element.getAttribute(`default-${field}`) : ''; return resourceValue; @@ -239,7 +239,7 @@ const WidgetMixin = { */ getWidget(field: string, isSet = false): WidgetInterface { if (this.isAlias(field)) field = field.split(' as ')[1]; - const widget = this.element.getAttribute('widget-' + field); + const widget = this.element.getAttribute(`widget-${field}`); if (widget) return this.widgetFromTagName(widget); if (this.getAction(field)) return this.widgetFromTagName('solid-action'); @@ -253,7 +253,7 @@ const WidgetMixin = { * @param field - string */ multiple(field: string): WidgetInterface | null { - const attribute = 'multiple-' + field; + const attribute = `multiple-${field}`; if (!this.element.hasAttribute(attribute)) return null; const widget = this.element.getAttribute(attribute) || this.defaultMultipleWidget; @@ -347,7 +347,7 @@ const WidgetMixin = { attrs.widget = this.getWidget(escapedField).tagName; if (this.getAction(escapedField) && resourceId) attrs.src = - this.element.getAttribute('src-' + escapedField) || resourceId; + this.element.getAttribute(`src-${escapedField}`) || resourceId; if (this.editable(escapedField) && resourceId) attrs['value-id'] = resourceId; return attrs; @@ -382,9 +382,9 @@ const WidgetMixin = { // Check if value is defined, and if the default widget is needed if ( (value === null || value === '') && - this.element.hasAttribute('default-widget-' + field) + this.element.hasAttribute(`default-widget-${field}`) ) { - tagName = this.element.getAttribute('default-widget-' + field); + tagName = this.element.getAttribute(`default-widget-${field}`); } // Set attributes to the widget // setAttribute set a string. Make sure null values are empty @@ -457,7 +457,7 @@ const WidgetMixin = { if (widget.component && initializing) widget.component.render(); const setFields = this.getSet(field); // Catch widget for the set if all these fields are empty - if (this.element.hasAttribute('empty-' + field)) { + if (this.element.hasAttribute(`empty-${field}`)) { let hasOnlyEmpty = true; for (const field of setFields) { const value: string = await this.getValue(field, this.resource); diff --git a/src/new-widgets/callbackMixins/richtextMixin.ts b/src/new-widgets/callbackMixins/richtextMixin.ts index 9ba42a6e..e719f67e 100644 --- a/src/new-widgets/callbackMixins/richtextMixin.ts +++ b/src/new-widgets/callbackMixins/richtextMixin.ts @@ -62,11 +62,11 @@ const RichtextMixin = { createHiddenRequiredInput() { const attributeName = this.getAttributeValue('name'); this.hiddenInput = document.querySelector( - `input[name="${attributeName + '-hidden'}"]`, + `input[name="${`${attributeName}-hidden`}"]`, ) as HTMLInputElement; if (!this.hiddenInput) { - this.hiddenInput = this.createHiddenInput(attributeName + '-hidden'); + this.hiddenInput = this.createHiddenInput(`${attributeName}-hidden`); this.element.appendChild(this.hiddenInput); this.addInvalidEventListener(); } diff --git a/src/widgets/baseWidget.ts b/src/widgets/baseWidget.ts index 9e10d3a4..df4182e7 100644 --- a/src/widgets/baseWidget.ts +++ b/src/widgets/baseWidget.ts @@ -139,7 +139,7 @@ export class BaseWidget extends HTMLElement { return ''; } get escapedValue(): string { - return ('' + this.value) + return `${this.value}` .replace(/&/g, '&') .replace(/'/g, ''') .replace(/"/g, '"'); -- GitLab From 916895cd011a3d4776e45a9b2fd9bfc3581c230b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Thu, 28 Nov 2024 16:30:37 +0100 Subject: [PATCH 47/66] fix `correctness/useImportExtensions` --- biome.jsonc | 3 + cypress/e2e/e2e/helpers.cy.ts | 2 +- cypress/e2e/unit/ComponentFactory.cy.ts | 2 +- cypress/e2e/unit/Compositor.cy.ts | 2 +- cypress/e2e/unit/helpers.cy.ts | 4 +- cypress/support/e2e.js | 2 +- src/components/solid-ac-checker.ts | 6 +- src/components/solid-delete.ts | 14 ++-- src/components/solid-display.ts | 32 ++++---- src/components/solid-form-search.ts | 18 ++--- src/components/solid-form.ts | 18 ++--- src/components/solid-lang.ts | 4 +- src/components/solid-member-add.ts | 14 ++-- src/components/solid-member-delete.ts | 12 +-- src/components/solid-membership.ts | 12 +-- src/components/solid-table.ts | 34 ++++----- src/components/solid-widget.ts | 12 +-- src/index.ts | 74 +++++++++---------- src/libs/Component.ts | 2 +- src/libs/ComponentFactory.ts | 6 +- src/libs/Compositor.ts | 2 +- src/libs/filter.ts | 4 +- src/libs/helpers.ts | 2 +- src/libs/interfaces.ts | 2 +- src/libs/store/custom-getter.ts | 4 +- src/libs/store/store.ts | 12 +-- src/mixins/attributeBinderMixin.ts | 4 +- src/mixins/contextMixin.ts | 2 +- src/mixins/counterMixin.ts | 4 +- src/mixins/federationMixin.ts | 6 +- src/mixins/filterMixin.ts | 8 +- src/mixins/grouperMixin.ts | 4 +- src/mixins/highlighterMixin.ts | 2 +- src/mixins/listMixin.ts | 4 +- src/mixins/paginateMixin.ts | 2 +- src/mixins/requiredMixin.ts | 2 +- src/mixins/sorterMixin.ts | 2 +- src/mixins/storeMixin.ts | 14 ++-- src/mixins/translationMixin.ts | 2 +- src/mixins/validationMixin.ts | 6 +- src/mixins/widgetMixin.ts | 12 ++- src/new-widgets/attributeMixins/index.ts | 16 ++-- src/new-widgets/baseWidgetMixin.ts | 4 +- .../callbackMixins/autocompletionMixin.ts | 6 +- src/new-widgets/callbackMixins/index.ts | 4 +- src/new-widgets/interfaces.ts | 2 +- src/new-widgets/new-widget-factory.ts | 18 ++--- .../templateAdditionMixins/addableMixin.ts | 4 +- .../templateAdditionMixins/index.ts | 6 +- .../templateAdditionMixins/labelLastMixin.ts | 2 +- .../templateAdditionMixins/labelMixin.ts | 4 +- .../templates/defaultTemplatesDirectory.ts | 2 +- .../templates/displayTemplatesDirectory.ts | 6 +- .../templates/formTemplatesDirectory.ts | 32 ++++---- .../templates/groupTemplatesDirectory.ts | 2 +- src/new-widgets/templates/index.ts | 8 +- .../templates/setTemplatesDirectory.ts | 2 +- .../templatesDependencies/editableMixin.ts | 6 +- .../templatesDependencies/formFileMixin.ts | 2 +- .../templatesDependencies/formRadioMixin.ts | 2 +- .../templatesDependencies/index.ts | 40 +++++----- .../multipleFormMixin.ts | 4 +- .../multipleselectFormMixin.ts | 4 +- .../templatesDependencies/rangeMixin.ts | 12 +-- .../autolinkMixin.ts | 2 +- .../valueTransformationMixins/dateMixin.ts | 2 +- .../dateTimeMixin.ts | 2 +- .../valueTransformationMixins/index.ts | 10 +-- .../markdownMixin.ts | 2 +- .../multilineMixin.ts | 2 +- .../valueTransformationMixins/oembedMixin.ts | 2 +- src/widgets/baseWidget.ts | 4 +- src/widgets/widget-factory.ts | 4 +- tsconfig.json | 1 + 74 files changed, 300 insertions(+), 292 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index 914d81e8..ae1a88f0 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -28,6 +28,9 @@ "suspicious": { "noExplicitAny": "off", "noAsyncPromiseExecutor": "off" + }, + "correctness": { + "useImportExtensions": "error" } } }, diff --git a/cypress/e2e/e2e/helpers.cy.ts b/cypress/e2e/e2e/helpers.cy.ts index 7e1aa85c..ef001068 100644 --- a/cypress/e2e/e2e/helpers.cy.ts +++ b/cypress/e2e/e2e/helpers.cy.ts @@ -1,4 +1,4 @@ -import sleep from '../sleep'; +import sleep from '../sleep.ts'; describe('helpers', function () { let helpers: typeof import('../../../src/libs/helpers'); diff --git a/cypress/e2e/unit/ComponentFactory.cy.ts b/cypress/e2e/unit/ComponentFactory.cy.ts index 91fcd91e..0cac4c78 100644 --- a/cypress/e2e/unit/ComponentFactory.cy.ts +++ b/cypress/e2e/unit/ComponentFactory.cy.ts @@ -1,4 +1,4 @@ -import { ComponentFactory } from '../../../src/libs/ComponentFactory'; +import { ComponentFactory } from '../../../src/libs/ComponentFactory.ts'; const MixinTestTwo = { name: 'mixin2', diff --git a/cypress/e2e/unit/Compositor.cy.ts b/cypress/e2e/unit/Compositor.cy.ts index 0706a2f1..10d3933e 100644 --- a/cypress/e2e/unit/Compositor.cy.ts +++ b/cypress/e2e/unit/Compositor.cy.ts @@ -1,4 +1,4 @@ -import { Compositor } from '../../../src/libs/Compositor'; +import { Compositor } from '../../../src/libs/Compositor.ts'; const MixinTestTwo = { name: 'mixin2', diff --git a/cypress/e2e/unit/helpers.cy.ts b/cypress/e2e/unit/helpers.cy.ts index b8ad05c3..16a1d65b 100644 --- a/cypress/e2e/unit/helpers.cy.ts +++ b/cypress/e2e/unit/helpers.cy.ts @@ -6,7 +6,7 @@ import { setDeepProperty, stringToDom, uniqID, -} from '../../../src/libs/helpers'; +} from '../../../src/libs/helpers.ts'; /** * uniqID @@ -294,7 +294,7 @@ describe('evalTemplateString', () => { // }) // }) // }) -import sleep from '../sleep'; +import sleep from '../sleep.ts'; describe('AsyncIterableBuilder', () => { it('create an asyncIterable', async () => { const { iterable, next } = new AsyncIterableBuilder<number>(); diff --git a/cypress/support/e2e.js b/cypress/support/e2e.js index 3cb1fbe5..d7d0b817 100644 --- a/cypress/support/e2e.js +++ b/cypress/support/e2e.js @@ -14,7 +14,7 @@ // *********************************************************** // Import commands.js using ES2015 syntax: -import './commands'; +import './commands.js'; // Alternatively you can use CommonJS syntax: // require('./commands') diff --git a/src/components/solid-ac-checker.ts b/src/components/solid-ac-checker.ts index e408c022..745c9e28 100644 --- a/src/components/solid-ac-checker.ts +++ b/src/components/solid-ac-checker.ts @@ -1,7 +1,7 @@ import JSONLDContextParser from 'jsonld-context-parser'; -import { Sib } from '../libs/Sib'; -import { trackRenderAsync } from '../logger'; -import { StoreMixin } from '../mixins/storeMixin'; +import { Sib } from '../libs/Sib.ts'; +import { trackRenderAsync } from '../logger.ts'; +import { StoreMixin } from '../mixins/storeMixin.ts'; export const SolidAcChecker = { name: 'solid-ac-checker', diff --git a/src/components/solid-delete.ts b/src/components/solid-delete.ts index e47f4bda..bc25e3de 100644 --- a/src/components/solid-delete.ts +++ b/src/components/solid-delete.ts @@ -1,12 +1,12 @@ -import { Sib } from '../libs/Sib'; -import { store } from '../libs/store/store'; -import { AttributeBinderMixin } from '../mixins/attributeBinderMixin'; -import { NextMixin } from '../mixins/nextMixin'; -import { ValidationMixin } from '../mixins/validationMixin'; +import { Sib } from '../libs/Sib.ts'; +import { store } from '../libs/store/store.ts'; +import { AttributeBinderMixin } from '../mixins/attributeBinderMixin.ts'; +import { NextMixin } from '../mixins/nextMixin.ts'; +import { ValidationMixin } from '../mixins/validationMixin.ts'; import { html, render } from 'lit'; -import { trackRenderAsync } from '../logger'; -import { ContextMixin } from '../mixins/contextMixin'; +import { trackRenderAsync } from '../logger.ts'; +import { ContextMixin } from '../mixins/contextMixin.ts'; export const SolidDelete = { name: 'solid-delete', diff --git a/src/components/solid-display.ts b/src/components/solid-display.ts index 7b3d8f2b..d2641148 100644 --- a/src/components/solid-display.ts +++ b/src/components/solid-display.ts @@ -1,22 +1,22 @@ -import { Sib } from '../libs/Sib'; -import { spread } from '../libs/lit-helpers'; -import { CounterMixin } from '../mixins/counterMixin'; -import { FederationMixin } from '../mixins/federationMixin'; -import { FilterMixin } from '../mixins/filterMixin'; -import { GrouperMixin } from '../mixins/grouperMixin'; -import { HighlighterMixin } from '../mixins/highlighterMixin'; -import { ListMixin } from '../mixins/listMixin'; -import { NextMixin } from '../mixins/nextMixin'; -import { PaginateMixin } from '../mixins/paginateMixin'; -import { RequiredMixin } from '../mixins/requiredMixin'; -import { SorterMixin } from '../mixins/sorterMixin'; -import { StoreMixin } from '../mixins/storeMixin'; -import { WidgetMixin } from '../mixins/widgetMixin'; +import { Sib } from '../libs/Sib.ts'; +import { spread } from '../libs/lit-helpers.ts'; +import { CounterMixin } from '../mixins/counterMixin.ts'; +import { FederationMixin } from '../mixins/federationMixin.ts'; +import { FilterMixin } from '../mixins/filterMixin.ts'; +import { GrouperMixin } from '../mixins/grouperMixin.ts'; +import { HighlighterMixin } from '../mixins/highlighterMixin.ts'; +import { ListMixin } from '../mixins/listMixin.ts'; +import { NextMixin } from '../mixins/nextMixin.ts'; +import { PaginateMixin } from '../mixins/paginateMixin.ts'; +import { RequiredMixin } from '../mixins/requiredMixin.ts'; +import { SorterMixin } from '../mixins/sorterMixin.ts'; +import { StoreMixin } from '../mixins/storeMixin.ts'; +import { WidgetMixin } from '../mixins/widgetMixin.ts'; import { html, render } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; -import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; -import { trackRenderAsync } from '../logger'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry.ts'; +import { trackRenderAsync } from '../logger.ts'; export const SolidDisplay = { name: 'solid-display', diff --git a/src/components/solid-form-search.ts b/src/components/solid-form-search.ts index 673b0422..86ee63b7 100644 --- a/src/components/solid-form-search.ts +++ b/src/components/solid-form-search.ts @@ -1,15 +1,15 @@ -import { Sib } from '../libs/Sib'; -import { AttributeBinderMixin } from '../mixins/attributeBinderMixin'; -import { ContextMixin } from '../mixins/contextMixin'; -import type { WidgetInterface } from '../mixins/interfaces'; -import { WidgetMixin } from '../mixins/widgetMixin'; -import { newWidgetFactory } from '../new-widgets/new-widget-factory'; +import { Sib } from '../libs/Sib.ts'; +import { AttributeBinderMixin } from '../mixins/attributeBinderMixin.ts'; +import { ContextMixin } from '../mixins/contextMixin.ts'; +import type { WidgetInterface } from '../mixins/interfaces.ts'; +import { WidgetMixin } from '../mixins/widgetMixin.ts'; +import { newWidgetFactory } from '../new-widgets/new-widget-factory.ts'; import { html, render } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; -import { uniqID } from '../libs/helpers'; -import type { FilterEventOptions, SearchQuery } from '../libs/interfaces'; -import { trackRenderAsync } from '../logger'; +import { uniqID } from '../libs/helpers.ts'; +import type { FilterEventOptions, SearchQuery } from '../libs/interfaces.ts'; +import { trackRenderAsync } from '../logger.ts'; export const SolidFormSearch = { name: 'solid-form-search', diff --git a/src/components/solid-form.ts b/src/components/solid-form.ts index ebbb1389..e3247089 100644 --- a/src/components/solid-form.ts +++ b/src/components/solid-form.ts @@ -1,15 +1,15 @@ -import { Sib } from '../libs/Sib'; -import { setDeepProperty, transformArrayToContainer } from '../libs/helpers'; -import { store } from '../libs/store/store'; -import type { WidgetInterface } from '../mixins/interfaces'; -import { NextMixin } from '../mixins/nextMixin'; -import { StoreMixin } from '../mixins/storeMixin'; -import { ValidationMixin } from '../mixins/validationMixin'; -import { WidgetMixin } from '../mixins/widgetMixin'; +import { Sib } from '../libs/Sib.ts'; +import { setDeepProperty, transformArrayToContainer } from '../libs/helpers.ts'; +import { store } from '../libs/store/store.ts'; +import type { WidgetInterface } from '../mixins/interfaces.ts'; +import { NextMixin } from '../mixins/nextMixin.ts'; +import { StoreMixin } from '../mixins/storeMixin.ts'; +import { ValidationMixin } from '../mixins/validationMixin.ts'; +import { WidgetMixin } from '../mixins/widgetMixin.ts'; import { html, render } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; -import { trackRenderAsync } from '../logger'; +import { trackRenderAsync } from '../logger.ts'; export const SolidForm = { name: 'solid-form', diff --git a/src/components/solid-lang.ts b/src/components/solid-lang.ts index 79e1a4f3..1f30d969 100644 --- a/src/components/solid-lang.ts +++ b/src/components/solid-lang.ts @@ -1,5 +1,5 @@ -import { Sib } from '../libs/Sib'; -import { store } from '../libs/store/store'; +import { Sib } from '../libs/Sib.ts'; +import { store } from '../libs/store/store.ts'; import { html, render } from 'lit'; diff --git a/src/components/solid-member-add.ts b/src/components/solid-member-add.ts index 7d4e2946..90dcc5d7 100644 --- a/src/components/solid-member-add.ts +++ b/src/components/solid-member-add.ts @@ -1,13 +1,13 @@ -import { Sib } from '../libs/Sib'; -import { base_context, store } from '../libs/store/store'; -import { NextMixin } from '../mixins/nextMixin'; -import { ValidationMixin } from '../mixins/validationMixin'; +import { Sib } from '../libs/Sib.ts'; +import { base_context, store } from '../libs/store/store.ts'; +import { NextMixin } from '../mixins/nextMixin.ts'; +import { ValidationMixin } from '../mixins/validationMixin.ts'; import { html, render } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; -import { ContextMixin } from '../mixins/contextMixin'; -import { StoreMixin } from '../mixins/storeMixin'; -import { newWidgetFactory } from '../new-widgets/new-widget-factory'; +import { ContextMixin } from '../mixins/contextMixin.ts'; +import { StoreMixin } from '../mixins/storeMixin.ts'; +import { newWidgetFactory } from '../new-widgets/new-widget-factory.ts'; export const SolidMemberAdd = { name: 'solid-member-add', diff --git a/src/components/solid-member-delete.ts b/src/components/solid-member-delete.ts index 29cd1308..34e7ee21 100644 --- a/src/components/solid-member-delete.ts +++ b/src/components/solid-member-delete.ts @@ -1,12 +1,12 @@ import { ifDefined } from 'lit/directives/if-defined.js'; -import { Sib } from '../libs/Sib'; -import { base_context, store } from '../libs/store/store'; -import { NextMixin } from '../mixins/nextMixin'; -import { ValidationMixin } from '../mixins/validationMixin'; +import { Sib } from '../libs/Sib.ts'; +import { base_context, store } from '../libs/store/store.ts'; +import { NextMixin } from '../mixins/nextMixin.ts'; +import { ValidationMixin } from '../mixins/validationMixin.ts'; import { html, render } from 'lit'; -import { trackRenderAsync } from '../logger'; -import { ContextMixin } from '../mixins/contextMixin'; +import { trackRenderAsync } from '../logger.ts'; +import { ContextMixin } from '../mixins/contextMixin.ts'; export const SolidMemberDelete = { name: 'solid-member-delete', diff --git a/src/components/solid-membership.ts b/src/components/solid-membership.ts index e5691751..49e92b2c 100644 --- a/src/components/solid-membership.ts +++ b/src/components/solid-membership.ts @@ -1,12 +1,12 @@ -import { Sib } from '../libs/Sib'; -import { base_context, store } from '../libs/store/store'; -import { NextMixin } from '../mixins/nextMixin'; -import { ValidationMixin } from '../mixins/validationMixin'; +import { Sib } from '../libs/Sib.ts'; +import { base_context, store } from '../libs/store/store.ts'; +import { NextMixin } from '../mixins/nextMixin.ts'; +import { ValidationMixin } from '../mixins/validationMixin.ts'; import { html, render } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; -import { trackRenderAsync } from '../logger'; -import { ContextMixin } from '../mixins/contextMixin'; +import { trackRenderAsync } from '../logger.ts'; +import { ContextMixin } from '../mixins/contextMixin.ts'; export const SolidMembership = { name: 'solid-membership', diff --git a/src/components/solid-table.ts b/src/components/solid-table.ts index 318d6df6..65060765 100644 --- a/src/components/solid-table.ts +++ b/src/components/solid-table.ts @@ -1,23 +1,23 @@ -import { Sib } from '../libs/Sib'; -import { store } from '../libs/store/store'; -import { CounterMixin } from '../mixins/counterMixin'; -import { FederationMixin } from '../mixins/federationMixin'; -import { FilterMixin } from '../mixins/filterMixin'; -import { GrouperMixin } from '../mixins/grouperMixin'; -import { HighlighterMixin } from '../mixins/highlighterMixin'; -import type { Resource } from '../mixins/interfaces'; -import { ListMixin } from '../mixins/listMixin'; -import { PaginateMixin } from '../mixins/paginateMixin'; -import { RequiredMixin } from '../mixins/requiredMixin'; -import { SorterMixin } from '../mixins/sorterMixin'; -import { StoreMixin } from '../mixins/storeMixin'; -import { WidgetMixin } from '../mixins/widgetMixin'; +import { Sib } from '../libs/Sib.ts'; +import { store } from '../libs/store/store.ts'; +import { CounterMixin } from '../mixins/counterMixin.ts'; +import { FederationMixin } from '../mixins/federationMixin.ts'; +import { FilterMixin } from '../mixins/filterMixin.ts'; +import { GrouperMixin } from '../mixins/grouperMixin.ts'; +import { HighlighterMixin } from '../mixins/highlighterMixin.ts'; +import type { Resource } from '../mixins/interfaces.ts'; +import { ListMixin } from '../mixins/listMixin.ts'; +import { PaginateMixin } from '../mixins/paginateMixin.ts'; +import { RequiredMixin } from '../mixins/requiredMixin.ts'; +import { SorterMixin } from '../mixins/sorterMixin.ts'; +import { StoreMixin } from '../mixins/storeMixin.ts'; +import { WidgetMixin } from '../mixins/widgetMixin.ts'; import { html, render } from 'lit'; import { until } from 'lit/directives/until.js'; -import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; -import { spread } from '../libs/lit-helpers'; -import { trackRenderAsync } from '../logger'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry.ts'; +import { spread } from '../libs/lit-helpers.ts'; +import { trackRenderAsync } from '../logger.ts'; export const SolidTable = { name: 'solid-table', diff --git a/src/components/solid-widget.ts b/src/components/solid-widget.ts index 1e889c71..0349f7c9 100644 --- a/src/components/solid-widget.ts +++ b/src/components/solid-widget.ts @@ -1,11 +1,11 @@ import { html, render } from 'lit'; import { unsafeHTML } from 'lit/directives/unsafe-html.js'; -import { Sib } from '../libs/Sib'; -import { evalTemplateString } from '../libs/helpers'; -import { StoreMixin } from '../mixins/storeMixin'; -import { ActionMixin } from '../new-widgets/attributeMixins/actionMixin'; -import { BaseWidgetMixin } from '../new-widgets/baseWidgetMixin'; -import { FormMixin } from '../new-widgets/templatesDependencies/formMixin'; +import { Sib } from '../libs/Sib.ts'; +import { evalTemplateString } from '../libs/helpers.ts'; +import { StoreMixin } from '../mixins/storeMixin.ts'; +import { ActionMixin } from '../new-widgets/attributeMixins/actionMixin.ts'; +import { BaseWidgetMixin } from '../new-widgets/baseWidgetMixin.ts'; +import { FormMixin } from '../new-widgets/templatesDependencies/formMixin.ts'; export const SolidWidget = { name: 'solid-widget', diff --git a/src/index.ts b/src/index.ts index 3feed9f0..28f6c5c4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,48 +1,48 @@ import './libs/polyfills.js'; -import { SolidAcChecker } from './components/solid-ac-checker'; -import { SolidDelete } from './components/solid-delete'; +import { SolidAcChecker } from './components/solid-ac-checker.ts'; +import { SolidDelete } from './components/solid-delete.ts'; // Components -import { SolidDisplay } from './components/solid-display'; -import { SolidForm } from './components/solid-form'; -import { SolidFormSearch } from './components/solid-form-search'; -import { SolidLang } from './components/solid-lang'; -import { SolidMemberAdd } from './components/solid-member-add'; -import { SolidMemberDelete } from './components/solid-member-delete'; -import { SolidMembership } from './components/solid-membership'; -import { SolidTable } from './components/solid-table'; -import { SolidWidget } from './components/solid-widget'; +import { SolidDisplay } from './components/solid-display.ts'; +import { SolidFormSearch } from './components/solid-form-search.ts'; +import { SolidForm } from './components/solid-form.ts'; +import { SolidLang } from './components/solid-lang.ts'; +import { SolidMemberAdd } from './components/solid-member-add.ts'; +import { SolidMemberDelete } from './components/solid-member-delete.ts'; +import { SolidMembership } from './components/solid-membership.ts'; +import { SolidTable } from './components/solid-table.ts'; +import { SolidWidget } from './components/solid-widget.ts'; // Mixins -import { CounterMixin } from './mixins/counterMixin'; -import { FederationMixin } from './mixins/federationMixin'; -import { FilterMixin } from './mixins/filterMixin'; -import { GrouperMixin } from './mixins/grouperMixin'; -import { HighlighterMixin } from './mixins/highlighterMixin'; -import { ListMixin } from './mixins/listMixin'; -import { NextMixin } from './mixins/nextMixin'; -import { PaginateMixin } from './mixins/paginateMixin'; -import { RequiredMixin } from './mixins/requiredMixin'; -import { SorterMixin } from './mixins/sorterMixin'; -import { StoreMixin } from './mixins/storeMixin'; -import { TranslationMixin } from './mixins/translationMixin'; -import { ValidationMixin } from './mixins/validationMixin'; -import { WidgetMixin } from './mixins/widgetMixin'; +import { CounterMixin } from './mixins/counterMixin.ts'; +import { FederationMixin } from './mixins/federationMixin.ts'; +import { FilterMixin } from './mixins/filterMixin.ts'; +import { GrouperMixin } from './mixins/grouperMixin.ts'; +import { HighlighterMixin } from './mixins/highlighterMixin.ts'; +import { ListMixin } from './mixins/listMixin.ts'; +import { NextMixin } from './mixins/nextMixin.ts'; +import { PaginateMixin } from './mixins/paginateMixin.ts'; +import { RequiredMixin } from './mixins/requiredMixin.ts'; +import { SorterMixin } from './mixins/sorterMixin.ts'; +import { StoreMixin } from './mixins/storeMixin.ts'; +import { TranslationMixin } from './mixins/translationMixin.ts'; +import { ValidationMixin } from './mixins/validationMixin.ts'; +import { WidgetMixin } from './mixins/widgetMixin.ts'; -import * as AttributeMixins from './new-widgets/attributeMixins'; -import { BaseWidgetMixin } from './new-widgets/baseWidgetMixin'; -import * as CallbackMixins from './new-widgets/callbackMixins'; +import * as AttributeMixins from './new-widgets/attributeMixins/index.ts'; +import { BaseWidgetMixin } from './new-widgets/baseWidgetMixin.ts'; +import * as CallbackMixins from './new-widgets/callbackMixins/index.ts'; // New widgets system -import { newWidgetFactory } from './new-widgets/new-widget-factory'; -import * as TemplateAdditionMixins from './new-widgets/templateAdditionMixins'; -import * as Templates from './new-widgets/templates'; -import * as TemplatesDependenciesMixins from './new-widgets/templatesDependencies'; +import { newWidgetFactory } from './new-widgets/new-widget-factory.ts'; +import * as TemplateAdditionMixins from './new-widgets/templateAdditionMixins/index.ts'; +import * as Templates from './new-widgets/templates/index.ts'; +import * as TemplatesDependenciesMixins from './new-widgets/templatesDependencies/index.ts'; -import { Sib } from './libs/Sib'; -import * as Helpers from './libs/helpers'; +import { Sib } from './libs/Sib.ts'; +import * as Helpers from './libs/helpers.ts'; // Libs -import { base_context as baseContext, store } from './libs/store/store'; -import SolidTemplateElement from './solid-template-element'; -import { widgetFactory } from './widgets/widget-factory'; +import { base_context as baseContext, store } from './libs/store/store.ts'; +import SolidTemplateElement from './solid-template-element.ts'; +import { widgetFactory } from './widgets/widget-factory.ts'; // lit-html import { html, render } from 'lit'; diff --git a/src/libs/Component.ts b/src/libs/Component.ts index 198942cb..9d7bc242 100644 --- a/src/libs/Component.ts +++ b/src/libs/Component.ts @@ -1,4 +1,4 @@ -import { Profiler } from '../logger'; +import { Profiler } from '../logger.ts'; import type { ComponentInterface } from './interfaces.js'; export abstract class Component implements ComponentInterface { diff --git a/src/libs/ComponentFactory.ts b/src/libs/ComponentFactory.ts index 290a7ebd..ba1b2c9a 100644 --- a/src/libs/ComponentFactory.ts +++ b/src/libs/ComponentFactory.ts @@ -1,12 +1,12 @@ -import { Component } from './Component'; -import { Compositor } from './Compositor'; +import { Component } from './Component.ts'; +import { Compositor } from './Compositor.ts'; import type { AccessorStaticInterface, ArrayOfHooksInterface, AttributesDefinitionInterface, ComponentConstructorInterface, MixinStaticInterface, -} from './interfaces'; +} from './interfaces.ts'; export const ComponentFactory = { build(component: MixinStaticInterface): ComponentConstructorInterface { diff --git a/src/libs/Compositor.ts b/src/libs/Compositor.ts index 3d7d5ead..3c9c72ae 100644 --- a/src/libs/Compositor.ts +++ b/src/libs/Compositor.ts @@ -4,7 +4,7 @@ import type { AttributesDefinitionInterface, ComponentStaticInterface, MixinStaticInterface, -} from './interfaces'; +} from './interfaces.ts'; const HOOKS = ['created', 'attached', 'detached']; const API = ['name', 'use', 'attributes', 'initialState', ...HOOKS]; diff --git a/src/libs/filter.ts b/src/libs/filter.ts index e4a26418..093c5ff9 100644 --- a/src/libs/filter.ts +++ b/src/libs/filter.ts @@ -3,8 +3,8 @@ import { findClosingBracketMatchIndex, parseFieldsString, uniqID, -} from './helpers'; -import type { Query, SearchQuery } from './interfaces'; +} from './helpers.ts'; +import type { Query, SearchQuery } from './interfaces.ts'; /** * Check if the field is a set diff --git a/src/libs/helpers.ts b/src/libs/helpers.ts index 103c8159..a6eac039 100644 --- a/src/libs/helpers.ts +++ b/src/libs/helpers.ts @@ -320,7 +320,7 @@ export default class AsyncIterableBuilder<Type> { import type { AsyncQuerySelectorAllType, AsyncQuerySelectorType, -} from './async-query-selector-types'; +} from './async-query-selector-types.ts'; const asyncQuerySelector: AsyncQuerySelectorType = ( selector: string, diff --git a/src/libs/interfaces.ts b/src/libs/interfaces.ts index 9321971d..144ae01b 100644 --- a/src/libs/interfaces.ts +++ b/src/libs/interfaces.ts @@ -1,4 +1,4 @@ -import type { Profiler } from '../logger'; +import type { Profiler } from '../logger.ts'; export interface AccessorStaticInterface { [key: string]: { diff --git a/src/libs/store/custom-getter.ts b/src/libs/store/custom-getter.ts index fb7ef068..b69e02c3 100644 --- a/src/libs/store/custom-getter.ts +++ b/src/libs/store/custom-getter.ts @@ -1,6 +1,6 @@ import JSONLDContextParser from 'jsonld-context-parser'; -import type { Resource } from '../../mixins/interfaces'; -import { store } from './store'; +import type { Resource } from '../../mixins/interfaces.ts'; +import { store } from './store.ts'; const ContextParser = JSONLDContextParser.ContextParser; diff --git a/src/libs/store/store.ts b/src/libs/store/store.ts index a1921ff8..96658909 100644 --- a/src/libs/store/store.ts +++ b/src/libs/store/store.ts @@ -2,14 +2,14 @@ import JSONLDContextParser from 'jsonld-context-parser'; import PubSub from 'pubsub-js'; import jsonld from 'jsonld'; -import { CustomGetter } from './custom-getter'; +import { CustomGetter } from './custom-getter.ts'; -import type { Resource } from '../../mixins/interfaces'; -import type { ServerSearchOptions } from './server-search'; -import { appendServerSearchToIri } from './server-search'; +import type { Resource } from '../../mixins/interfaces.ts'; +import type { ServerSearchOptions } from './server-search.ts'; +import { appendServerSearchToIri } from './server-search.ts'; -import type { ServerPaginationOptions } from './server-pagination'; -import { appendServerPaginationToIri } from './server-pagination'; +import type { ServerPaginationOptions } from './server-pagination.ts'; +import { appendServerPaginationToIri } from './server-pagination.ts'; const ContextParser = JSONLDContextParser.ContextParser; const myParser = new ContextParser(); diff --git a/src/mixins/attributeBinderMixin.ts b/src/mixins/attributeBinderMixin.ts index 0258d782..2a09f117 100644 --- a/src/mixins/attributeBinderMixin.ts +++ b/src/mixins/attributeBinderMixin.ts @@ -1,5 +1,5 @@ -import { base_context, store } from '../libs/store/store'; -import type { Resource } from './interfaces'; +import { base_context, store } from '../libs/store/store.ts'; +import type { Resource } from './interfaces.ts'; const AttributeBinderMixin = { name: 'attribute-binder-mixin', diff --git a/src/mixins/contextMixin.ts b/src/mixins/contextMixin.ts index d79d9a92..0e071f42 100644 --- a/src/mixins/contextMixin.ts +++ b/src/mixins/contextMixin.ts @@ -1,4 +1,4 @@ -import { base_context } from '../libs/store/store'; +import { base_context } from '../libs/store/store.ts'; const ContextMixin = { name: 'store-mixin', diff --git a/src/mixins/counterMixin.ts b/src/mixins/counterMixin.ts index c981cd90..994ea0e9 100644 --- a/src/mixins/counterMixin.ts +++ b/src/mixins/counterMixin.ts @@ -1,7 +1,7 @@ import { html } from 'lit'; import { unsafeHTML } from 'lit/directives/unsafe-html.js'; -import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; -import { evalTemplateString } from '../libs/helpers'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry.ts'; +import { evalTemplateString } from '../libs/helpers.ts'; const CounterMixin = { name: 'counter-mixin', diff --git a/src/mixins/federationMixin.ts b/src/mixins/federationMixin.ts index 6dd269e5..9b1f8fbc 100644 --- a/src/mixins/federationMixin.ts +++ b/src/mixins/federationMixin.ts @@ -1,6 +1,6 @@ -import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; -import { store } from '../libs/store/store'; -import type { Resource } from './interfaces'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry.ts'; +import { store } from '../libs/store/store.ts'; +import type { Resource } from './interfaces.ts'; const FederationMixin = { name: 'federation-mixin', diff --git a/src/mixins/filterMixin.ts b/src/mixins/filterMixin.ts index 5cfab947..b3b1c0ac 100644 --- a/src/mixins/filterMixin.ts +++ b/src/mixins/filterMixin.ts @@ -1,7 +1,7 @@ -import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; -import { searchInResources } from '../libs/filter'; -import type { SearchQuery } from '../libs/interfaces'; -import type { ServerSearchOptions } from '../libs/store/server-search'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry.ts'; +import { searchInResources } from '../libs/filter.ts'; +import type { SearchQuery } from '../libs/interfaces.ts'; +import type { ServerSearchOptions } from '../libs/store/server-search.ts'; const FilterMixin = { name: 'filter-mixin', diff --git a/src/mixins/grouperMixin.ts b/src/mixins/grouperMixin.ts index 10f65337..85264d1d 100644 --- a/src/mixins/grouperMixin.ts +++ b/src/mixins/grouperMixin.ts @@ -1,5 +1,5 @@ -import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; -import { generalComparator } from '../libs/helpers'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry.ts'; +import { generalComparator } from '../libs/helpers.ts'; const GrouperMixin = { name: 'grouper-mixin', diff --git a/src/mixins/highlighterMixin.ts b/src/mixins/highlighterMixin.ts index 96062d61..852d4d12 100644 --- a/src/mixins/highlighterMixin.ts +++ b/src/mixins/highlighterMixin.ts @@ -1,4 +1,4 @@ -import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry.ts'; const HighlighterMixin = { name: 'highlighter-mixin', diff --git a/src/mixins/listMixin.ts b/src/mixins/listMixin.ts index 467b94d4..6492492c 100644 --- a/src/mixins/listMixin.ts +++ b/src/mixins/listMixin.ts @@ -1,7 +1,7 @@ import { html, render } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; -import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; -import { preHTML } from '../libs/lit-helpers'; +import { PostProcessorRegistry } from '../libs/PostProcessorRegistry.ts'; +import { preHTML } from '../libs/lit-helpers.ts'; const ListMixin = { name: 'list-mixin', diff --git a/src/mixins/paginateMixin.ts b/src/mixins/paginateMixin.ts index 6fae4f33..f68be13f 100644 --- a/src/mixins/paginateMixin.ts +++ b/src/mixins/paginateMixin.ts @@ -1,5 +1,5 @@ import { type TemplateResult, html } from 'lit'; -import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry.ts'; const PaginateMixin = { name: 'paginate-mixin', diff --git a/src/mixins/requiredMixin.ts b/src/mixins/requiredMixin.ts index 5c12b8ae..9c560fb4 100644 --- a/src/mixins/requiredMixin.ts +++ b/src/mixins/requiredMixin.ts @@ -1,4 +1,4 @@ -import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry.ts'; const RequiredMixin = { name: 'required-mixin', diff --git a/src/mixins/sorterMixin.ts b/src/mixins/sorterMixin.ts index 35b9b099..e5cd36b3 100644 --- a/src/mixins/sorterMixin.ts +++ b/src/mixins/sorterMixin.ts @@ -1,4 +1,4 @@ -import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../libs/PostProcessorRegistry.ts'; const SorterMixin = { name: 'sorter-mixin', diff --git a/src/mixins/storeMixin.ts b/src/mixins/storeMixin.ts index b6a6201a..07432fde 100644 --- a/src/mixins/storeMixin.ts +++ b/src/mixins/storeMixin.ts @@ -1,13 +1,13 @@ -import { formatAttributesToServerPaginationOptions } from '../libs/store/server-pagination'; +import { formatAttributesToServerPaginationOptions } from '../libs/store/server-pagination.ts'; import { formatAttributesToServerSearchOptions, mergeServerSearchOptions, -} from '../libs/store/server-search'; -import { store } from '../libs/store/store'; -import { AttributeBinderMixin } from './attributeBinderMixin'; -import { ContextMixin } from './contextMixin'; -import type { Resource } from './interfaces'; -import { ServerPaginationMixin } from './serverPaginationMixin'; +} from '../libs/store/server-search.ts'; +import { store } from '../libs/store/store.ts'; +import { AttributeBinderMixin } from './attributeBinderMixin.ts'; +import { ContextMixin } from './contextMixin.ts'; +import type { Resource } from './interfaces.ts'; +import { ServerPaginationMixin } from './serverPaginationMixin.ts'; const StoreMixin = { name: 'store-mixin', diff --git a/src/mixins/translationMixin.ts b/src/mixins/translationMixin.ts index 55223a41..6ba822a2 100644 --- a/src/mixins/translationMixin.ts +++ b/src/mixins/translationMixin.ts @@ -1,4 +1,4 @@ -import { store } from '../libs/store/store'; +import { store } from '../libs/store/store.ts'; const TranslationMixin = { name: 'translation-mixin', diff --git a/src/mixins/validationMixin.ts b/src/mixins/validationMixin.ts index d2d1d732..770ad325 100644 --- a/src/mixins/validationMixin.ts +++ b/src/mixins/validationMixin.ts @@ -1,9 +1,9 @@ import dialogPolyfill from 'dialog-polyfill'; import { html } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; -import { uniqID } from '../libs/helpers'; -import { preHTML } from '../libs/lit-helpers'; -import { TranslationMixin } from './translationMixin'; +import { uniqID } from '../libs/helpers.ts'; +import { preHTML } from '../libs/lit-helpers.ts'; +import { TranslationMixin } from './translationMixin.ts'; const ValidationMixin = { name: 'validation-mixin', diff --git a/src/mixins/widgetMixin.ts b/src/mixins/widgetMixin.ts index 6fb172c7..954b1ffa 100644 --- a/src/mixins/widgetMixin.ts +++ b/src/mixins/widgetMixin.ts @@ -3,10 +3,14 @@ import { ifDefined } from 'lit/directives/if-defined.js'; import { findClosingBracketMatchIndex, parseFieldsString, -} from '../libs/helpers'; -import { preHTML, spread } from '../libs/lit-helpers'; -import { newWidgetFactory } from '../new-widgets/new-widget-factory'; -import { type Resource, type WidgetInterface, WidgetType } from './interfaces'; +} from '../libs/helpers.ts'; +import { preHTML, spread } from '../libs/lit-helpers.ts'; +import { newWidgetFactory } from '../new-widgets/new-widget-factory.ts'; +import { + type Resource, + type WidgetInterface, + WidgetType, +} from './interfaces.ts'; const WidgetMixin = { name: 'widget-mixin', diff --git a/src/new-widgets/attributeMixins/index.ts b/src/new-widgets/attributeMixins/index.ts index 3ab60217..7032f711 100644 --- a/src/new-widgets/attributeMixins/index.ts +++ b/src/new-widgets/attributeMixins/index.ts @@ -1,11 +1,11 @@ -import { ActionMixin } from './actionMixin'; -import { BlankMixin } from './blankMixin'; -import { BooleanMixin } from './booleanMixin'; -import { MailtoMixin } from './mailtoMixin'; -import { MultipleMixin } from './multipleMixin'; -import { NumberMixin } from './numberMixin'; -import { PlaceholderMixin } from './placeholderMixin'; -import { TelMixin } from './telMixin'; +import { ActionMixin } from './actionMixin.ts'; +import { BlankMixin } from './blankMixin.ts'; +import { BooleanMixin } from './booleanMixin.ts'; +import { MailtoMixin } from './mailtoMixin.ts'; +import { MultipleMixin } from './multipleMixin.ts'; +import { NumberMixin } from './numberMixin.ts'; +import { PlaceholderMixin } from './placeholderMixin.ts'; +import { TelMixin } from './telMixin.ts'; const attributeDirectory = { multiple: MultipleMixin, diff --git a/src/new-widgets/baseWidgetMixin.ts b/src/new-widgets/baseWidgetMixin.ts index 8f2b04d1..3e8e4c3a 100644 --- a/src/new-widgets/baseWidgetMixin.ts +++ b/src/new-widgets/baseWidgetMixin.ts @@ -1,5 +1,5 @@ -import { PostProcessorRegistry } from '../libs/PostProcessorRegistry'; -import type { Template } from './interfaces'; +import { PostProcessorRegistry } from '../libs/PostProcessorRegistry.ts'; +import type { Template } from './interfaces.ts'; import { render } from 'lit'; diff --git a/src/new-widgets/callbackMixins/autocompletionMixin.ts b/src/new-widgets/callbackMixins/autocompletionMixin.ts index 0f9b54af..ac7c156a 100644 --- a/src/new-widgets/callbackMixins/autocompletionMixin.ts +++ b/src/new-widgets/callbackMixins/autocompletionMixin.ts @@ -1,11 +1,11 @@ import SlimSelect from 'slim-select'; -import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.ts'; import { asyncQuerySelector, fuzzyCompare, importInlineCSS, -} from '../../libs/helpers'; -import { TranslationMixin } from '../../mixins/translationMixin'; +} from '../../libs/helpers.ts'; +import { TranslationMixin } from '../../mixins/translationMixin.ts'; const AutocompletionMixin = { name: 'autocompletion-mixin', diff --git a/src/new-widgets/callbackMixins/index.ts b/src/new-widgets/callbackMixins/index.ts index 3f288db3..162a8ada 100644 --- a/src/new-widgets/callbackMixins/index.ts +++ b/src/new-widgets/callbackMixins/index.ts @@ -1,5 +1,5 @@ -import { AutocompletionMixin } from './autocompletionMixin'; -import { RichtextMixin } from './richtextMixin'; +import { AutocompletionMixin } from './autocompletionMixin.ts'; +import { RichtextMixin } from './richtextMixin.ts'; const callbackDirectory = { autocompletion: AutocompletionMixin, diff --git a/src/new-widgets/interfaces.ts b/src/new-widgets/interfaces.ts index 1b33dc64..01e77e40 100644 --- a/src/new-widgets/interfaces.ts +++ b/src/new-widgets/interfaces.ts @@ -1,4 +1,4 @@ -import type { MixinStaticInterface } from '../libs/interfaces'; +import type { MixinStaticInterface } from '../libs/interfaces.ts'; export interface Template { template: Function; diff --git a/src/new-widgets/new-widget-factory.ts b/src/new-widgets/new-widget-factory.ts index 02c3f13e..4f8a4ac4 100644 --- a/src/new-widgets/new-widget-factory.ts +++ b/src/new-widgets/new-widget-factory.ts @@ -1,18 +1,18 @@ -import { Sib } from '../libs/Sib'; -import type { MixinStaticInterface } from '../libs/interfaces'; -import { attributeDirectory } from './attributeMixins/index'; -import { BaseWidgetMixin } from './baseWidgetMixin'; -import { callbackDirectory } from './callbackMixins/index'; -import type { Template, WidgetMixinsInterface } from './interfaces'; -import { templateAdditionDirectory } from './templateAdditionMixins/index'; +import { Sib } from '../libs/Sib.ts'; +import type { MixinStaticInterface } from '../libs/interfaces.ts'; +import { attributeDirectory } from './attributeMixins/index.ts'; +import { BaseWidgetMixin } from './baseWidgetMixin.ts'; +import { callbackDirectory } from './callbackMixins/index.ts'; +import type { Template, WidgetMixinsInterface } from './interfaces.ts'; +import { templateAdditionDirectory } from './templateAdditionMixins/index.ts'; import { defaultTemplates, displayTemplates, formTemplates, groupTemplates, setTemplates, -} from './templates/index'; -import { valueTransformationDirectory } from './valueTransformationMixins/index'; +} from './templates/index.ts'; +import { valueTransformationDirectory } from './valueTransformationMixins/index.ts'; const valueTransformationKeys = Object.keys(valueTransformationDirectory); const attributeKeys = Object.keys(attributeDirectory); diff --git a/src/new-widgets/templateAdditionMixins/addableMixin.ts b/src/new-widgets/templateAdditionMixins/addableMixin.ts index 6045249e..fb1c571d 100644 --- a/src/new-widgets/templateAdditionMixins/addableMixin.ts +++ b/src/new-widgets/templateAdditionMixins/addableMixin.ts @@ -1,5 +1,5 @@ -import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; -import { spread } from '../../libs/lit-helpers'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.ts'; +import { spread } from '../../libs/lit-helpers.ts'; import { html } from 'lit'; diff --git a/src/new-widgets/templateAdditionMixins/index.ts b/src/new-widgets/templateAdditionMixins/index.ts index d0525f91..8e874eee 100644 --- a/src/new-widgets/templateAdditionMixins/index.ts +++ b/src/new-widgets/templateAdditionMixins/index.ts @@ -1,6 +1,6 @@ -import { AddableMixin } from './addableMixin'; -import { LabelLastMixin } from './labelLastMixin'; -import { LabelMixin } from './labelMixin'; +import { AddableMixin } from './addableMixin.ts'; +import { LabelLastMixin } from './labelLastMixin.ts'; +import { LabelMixin } from './labelMixin.ts'; /** * DOM Additions diff --git a/src/new-widgets/templateAdditionMixins/labelLastMixin.ts b/src/new-widgets/templateAdditionMixins/labelLastMixin.ts index b9a87223..aabea616 100644 --- a/src/new-widgets/templateAdditionMixins/labelLastMixin.ts +++ b/src/new-widgets/templateAdditionMixins/labelLastMixin.ts @@ -1,5 +1,5 @@ import { html } from 'lit'; -import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.ts'; const LabelLastMixin = { name: 'label-last-mixin', diff --git a/src/new-widgets/templateAdditionMixins/labelMixin.ts b/src/new-widgets/templateAdditionMixins/labelMixin.ts index 22858d3b..d607425b 100644 --- a/src/new-widgets/templateAdditionMixins/labelMixin.ts +++ b/src/new-widgets/templateAdditionMixins/labelMixin.ts @@ -1,6 +1,6 @@ import { html } from 'lit'; -import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; -import { uniqID } from '../../libs/helpers'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.ts'; +import { uniqID } from '../../libs/helpers.ts'; const LabelMixin = { name: 'label-mixin', diff --git a/src/new-widgets/templates/defaultTemplatesDirectory.ts b/src/new-widgets/templates/defaultTemplatesDirectory.ts index faed3415..1bcdbed6 100644 --- a/src/new-widgets/templates/defaultTemplatesDirectory.ts +++ b/src/new-widgets/templates/defaultTemplatesDirectory.ts @@ -1,6 +1,6 @@ import { html } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; -import { LinkTextMixin } from '../templatesDependencies/linkTextMixin'; +import { LinkTextMixin } from '../templatesDependencies/linkTextMixin.ts'; export const defaultTemplates = { action: { diff --git a/src/new-widgets/templates/displayTemplatesDirectory.ts b/src/new-widgets/templates/displayTemplatesDirectory.ts index 0b066316..3de48ca3 100644 --- a/src/new-widgets/templates/displayTemplatesDirectory.ts +++ b/src/new-widgets/templates/displayTemplatesDirectory.ts @@ -1,6 +1,6 @@ -import { AltMixin } from '../templatesDependencies/altMixin'; -import { EditableMixin } from '../templatesDependencies/editableMixin'; -import { LinkTextMixin } from '../templatesDependencies/linkTextMixin'; +import { AltMixin } from '../templatesDependencies/altMixin.ts'; +import { EditableMixin } from '../templatesDependencies/editableMixin.ts'; +import { LinkTextMixin } from '../templatesDependencies/linkTextMixin.ts'; import { html } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; diff --git a/src/new-widgets/templates/formTemplatesDirectory.ts b/src/new-widgets/templates/formTemplatesDirectory.ts index 734eeaa8..599f389d 100644 --- a/src/new-widgets/templates/formTemplatesDirectory.ts +++ b/src/new-widgets/templates/formTemplatesDirectory.ts @@ -1,19 +1,19 @@ -import { FilterRangeFormMixin } from '../templatesDependencies/filterRangeFormMixin'; -import { FormCheckboxMixin } from '../templatesDependencies/formCheckboxMixin'; -import { FormCheckboxesMixin } from '../templatesDependencies/formCheckboxesMixin'; -import { FormDropdownMixin } from '../templatesDependencies/formDropdownMixin'; -import { FormFileMixin } from '../templatesDependencies/formFileMixin'; -import { FormLengthMixin } from '../templatesDependencies/formLengthMixin'; -import { FormMinMaxMixin } from '../templatesDependencies/formMinMaxMixin'; -import { FormMixin } from '../templatesDependencies/formMixin'; -import { FormNumberMixin } from '../templatesDependencies/formNumberMixin'; -import { FormRadioMixin } from '../templatesDependencies/formRadioMixin'; -import { FormStepMixin } from '../templatesDependencies/formStepMixin'; -import { MultipleFormMixin } from '../templatesDependencies/multipleFormMixin'; -import { MultipleselectFormMixin } from '../templatesDependencies/multipleselectFormMixin'; -import { PatternMixin } from '../templatesDependencies/patternMixin'; -import { RangeMixin } from '../templatesDependencies/rangeMixin'; -import { ValueRichtextMixin } from '../templatesDependencies/valueRichtextMixin'; +import { FilterRangeFormMixin } from '../templatesDependencies/filterRangeFormMixin.ts'; +import { FormCheckboxMixin } from '../templatesDependencies/formCheckboxMixin.ts'; +import { FormCheckboxesMixin } from '../templatesDependencies/formCheckboxesMixin.ts'; +import { FormDropdownMixin } from '../templatesDependencies/formDropdownMixin.ts'; +import { FormFileMixin } from '../templatesDependencies/formFileMixin.ts'; +import { FormLengthMixin } from '../templatesDependencies/formLengthMixin.ts'; +import { FormMinMaxMixin } from '../templatesDependencies/formMinMaxMixin.ts'; +import { FormMixin } from '../templatesDependencies/formMixin.ts'; +import { FormNumberMixin } from '../templatesDependencies/formNumberMixin.ts'; +import { FormRadioMixin } from '../templatesDependencies/formRadioMixin.ts'; +import { FormStepMixin } from '../templatesDependencies/formStepMixin.ts'; +import { MultipleFormMixin } from '../templatesDependencies/multipleFormMixin.ts'; +import { MultipleselectFormMixin } from '../templatesDependencies/multipleselectFormMixin.ts'; +import { PatternMixin } from '../templatesDependencies/patternMixin.ts'; +import { RangeMixin } from '../templatesDependencies/rangeMixin.ts'; +import { ValueRichtextMixin } from '../templatesDependencies/valueRichtextMixin.ts'; import { html } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; diff --git a/src/new-widgets/templates/groupTemplatesDirectory.ts b/src/new-widgets/templates/groupTemplatesDirectory.ts index c1c4997b..77799cb5 100644 --- a/src/new-widgets/templates/groupTemplatesDirectory.ts +++ b/src/new-widgets/templates/groupTemplatesDirectory.ts @@ -1,5 +1,5 @@ import { html } from 'lit'; -import { SetMixin } from '../templatesDependencies/setMixin'; +import { SetMixin } from '../templatesDependencies/setMixin.ts'; export const groupTemplates = { default: { diff --git a/src/new-widgets/templates/index.ts b/src/new-widgets/templates/index.ts index ceb4a416..e05514eb 100644 --- a/src/new-widgets/templates/index.ts +++ b/src/new-widgets/templates/index.ts @@ -1,8 +1,8 @@ -import { defaultTemplates } from './defaultTemplatesDirectory'; -import { displayTemplates } from './displayTemplatesDirectory'; -import { formTemplates } from './formTemplatesDirectory'; +import { defaultTemplates } from './defaultTemplatesDirectory.ts'; +import { displayTemplates } from './displayTemplatesDirectory.ts'; +import { formTemplates } from './formTemplatesDirectory.ts'; import { groupTemplates } from './groupTemplatesDirectory.js'; -import { setTemplates } from './setTemplatesDirectory'; +import { setTemplates } from './setTemplatesDirectory.ts'; export { defaultTemplates, diff --git a/src/new-widgets/templates/setTemplatesDirectory.ts b/src/new-widgets/templates/setTemplatesDirectory.ts index 59c8de16..155b8d8c 100644 --- a/src/new-widgets/templates/setTemplatesDirectory.ts +++ b/src/new-widgets/templates/setTemplatesDirectory.ts @@ -1,5 +1,5 @@ import { html } from 'lit'; -import { SetMixin } from '../templatesDependencies/setMixin'; +import { SetMixin } from '../templatesDependencies/setMixin.ts'; export const setTemplates = { default: { diff --git a/src/new-widgets/templatesDependencies/editableMixin.ts b/src/new-widgets/templatesDependencies/editableMixin.ts index f2d57dd7..1ef096dc 100644 --- a/src/new-widgets/templatesDependencies/editableMixin.ts +++ b/src/new-widgets/templatesDependencies/editableMixin.ts @@ -1,8 +1,8 @@ -import { store } from '../../libs/store/store'; -import { StoreMixin } from '../../mixins/storeMixin'; +import { store } from '../../libs/store/store.ts'; +import { StoreMixin } from '../../mixins/storeMixin.ts'; import { html } from 'lit'; -import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.ts'; const EditableMixin = { name: 'editable-mixin', diff --git a/src/new-widgets/templatesDependencies/formFileMixin.ts b/src/new-widgets/templatesDependencies/formFileMixin.ts index 5c6a919b..91a54df1 100644 --- a/src/new-widgets/templatesDependencies/formFileMixin.ts +++ b/src/new-widgets/templatesDependencies/formFileMixin.ts @@ -1,4 +1,4 @@ -import { store } from '../../libs/store/store'; +import { store } from '../../libs/store/store.ts'; const FormFileMixin = { name: 'form-file-mixin', diff --git a/src/new-widgets/templatesDependencies/formRadioMixin.ts b/src/new-widgets/templatesDependencies/formRadioMixin.ts index 7b1feb29..d672b80a 100644 --- a/src/new-widgets/templatesDependencies/formRadioMixin.ts +++ b/src/new-widgets/templatesDependencies/formRadioMixin.ts @@ -1,4 +1,4 @@ -import { uniqID } from '../../libs/helpers'; +import { uniqID } from '../../libs/helpers.ts'; const FormRadioMixin = { name: 'form-radio-mixin', diff --git a/src/new-widgets/templatesDependencies/index.ts b/src/new-widgets/templatesDependencies/index.ts index eaf1987a..6f4d7c22 100644 --- a/src/new-widgets/templatesDependencies/index.ts +++ b/src/new-widgets/templatesDependencies/index.ts @@ -1,23 +1,23 @@ -import { AltMixin } from './altMixin'; -import { EditableMixin } from './editableMixin'; -import { FilterRangeFormMixin } from './filterRangeFormMixin'; -import { FormCheckboxMixin } from './formCheckboxMixin'; -import { FormCheckboxesMixin } from './formCheckboxesMixin'; -import { FormDropdownMixin } from './formDropdownMixin'; -import { FormFileMixin } from './formFileMixin'; -import { FormLengthMixin } from './formLengthMixin'; -import { FormMinMaxMixin } from './formMinMaxMixin'; -import { FormMixin } from './formMixin'; -import { FormNumberMixin } from './formNumberMixin'; -import { FormRadioMixin } from './formRadioMixin'; -import { FormStepMixin } from './formStepMixin'; -import { LinkTextMixin } from './linkTextMixin'; -import { MultipleFormMixin } from './multipleFormMixin'; -import { MultipleselectFormMixin } from './multipleselectFormMixin'; -import { PatternMixin } from './patternMixin'; -import { RangeMixin } from './rangeMixin'; -import { SetMixin } from './setMixin'; -import { ValueRichtextMixin } from './valueRichtextMixin'; +import { AltMixin } from './altMixin.ts'; +import { EditableMixin } from './editableMixin.ts'; +import { FilterRangeFormMixin } from './filterRangeFormMixin.ts'; +import { FormCheckboxMixin } from './formCheckboxMixin.ts'; +import { FormCheckboxesMixin } from './formCheckboxesMixin.ts'; +import { FormDropdownMixin } from './formDropdownMixin.ts'; +import { FormFileMixin } from './formFileMixin.ts'; +import { FormLengthMixin } from './formLengthMixin.ts'; +import { FormMinMaxMixin } from './formMinMaxMixin.ts'; +import { FormMixin } from './formMixin.ts'; +import { FormNumberMixin } from './formNumberMixin.ts'; +import { FormRadioMixin } from './formRadioMixin.ts'; +import { FormStepMixin } from './formStepMixin.ts'; +import { LinkTextMixin } from './linkTextMixin.ts'; +import { MultipleFormMixin } from './multipleFormMixin.ts'; +import { MultipleselectFormMixin } from './multipleselectFormMixin.ts'; +import { PatternMixin } from './patternMixin.ts'; +import { RangeMixin } from './rangeMixin.ts'; +import { SetMixin } from './setMixin.ts'; +import { ValueRichtextMixin } from './valueRichtextMixin.ts'; /** * Template Depenedices Additions diff --git a/src/new-widgets/templatesDependencies/multipleFormMixin.ts b/src/new-widgets/templatesDependencies/multipleFormMixin.ts index b404da84..3b6af795 100644 --- a/src/new-widgets/templatesDependencies/multipleFormMixin.ts +++ b/src/new-widgets/templatesDependencies/multipleFormMixin.ts @@ -1,5 +1,5 @@ -import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; -import { StoreMixin } from '../../mixins/storeMixin'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.ts'; +import { StoreMixin } from '../../mixins/storeMixin.ts'; const MultipleFormMixin = { name: 'multiple-form-mixin', diff --git a/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts b/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts index 4e2a816e..68c1766b 100644 --- a/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts +++ b/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts @@ -1,5 +1,5 @@ -import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; -import { StoreMixin } from '../../mixins/storeMixin'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.ts'; +import { StoreMixin } from '../../mixins/storeMixin.ts'; const MultipleselectFormMixin = { name: 'multipleselect-form-mixin', diff --git a/src/new-widgets/templatesDependencies/rangeMixin.ts b/src/new-widgets/templatesDependencies/rangeMixin.ts index 7e25cc43..d7b9a2ab 100644 --- a/src/new-widgets/templatesDependencies/rangeMixin.ts +++ b/src/new-widgets/templatesDependencies/rangeMixin.ts @@ -1,9 +1,9 @@ -import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; -import { base_context, store } from '../../libs/store/store'; -import { FederationMixin } from '../../mixins/federationMixin'; -import type { Resource } from '../../mixins/interfaces'; -import { SorterMixin } from '../../mixins/sorterMixin'; -import { StoreMixin } from '../../mixins/storeMixin'; +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.ts'; +import { base_context, store } from '../../libs/store/store.ts'; +import { FederationMixin } from '../../mixins/federationMixin.ts'; +import type { Resource } from '../../mixins/interfaces.ts'; +import { SorterMixin } from '../../mixins/sorterMixin.ts'; +import { StoreMixin } from '../../mixins/storeMixin.ts'; const RangeMixin = { name: 'range-mixin', diff --git a/src/new-widgets/valueTransformationMixins/autolinkMixin.ts b/src/new-widgets/valueTransformationMixins/autolinkMixin.ts index 58d52a9c..148d8061 100644 --- a/src/new-widgets/valueTransformationMixins/autolinkMixin.ts +++ b/src/new-widgets/valueTransformationMixins/autolinkMixin.ts @@ -1,5 +1,5 @@ import { Autolinker } from 'autolinker'; -import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.ts'; const AutolinkMixin = { name: 'autolink-mixin', diff --git a/src/new-widgets/valueTransformationMixins/dateMixin.ts b/src/new-widgets/valueTransformationMixins/dateMixin.ts index 1fd1b4b5..ee1ec183 100644 --- a/src/new-widgets/valueTransformationMixins/dateMixin.ts +++ b/src/new-widgets/valueTransformationMixins/dateMixin.ts @@ -1,4 +1,4 @@ -import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.ts'; const DateMixin = { name: 'date-mixin', diff --git a/src/new-widgets/valueTransformationMixins/dateTimeMixin.ts b/src/new-widgets/valueTransformationMixins/dateTimeMixin.ts index c18f59f5..b09c979c 100644 --- a/src/new-widgets/valueTransformationMixins/dateTimeMixin.ts +++ b/src/new-widgets/valueTransformationMixins/dateTimeMixin.ts @@ -1,4 +1,4 @@ -import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.ts'; const DateTimeMixin = { name: 'date-time-mixin', diff --git a/src/new-widgets/valueTransformationMixins/index.ts b/src/new-widgets/valueTransformationMixins/index.ts index 032ae31d..16dba1df 100644 --- a/src/new-widgets/valueTransformationMixins/index.ts +++ b/src/new-widgets/valueTransformationMixins/index.ts @@ -1,9 +1,9 @@ -import { AutolinkMixin } from './autolinkMixin'; -import { DateMixin } from './dateMixin'; -import { DateTimeMixin } from './dateTimeMixin'; +import { AutolinkMixin } from './autolinkMixin.ts'; +import { DateMixin } from './dateMixin.ts'; +import { DateTimeMixin } from './dateTimeMixin.ts'; import { MarkdownMixin } from './markdownMixin.js'; -import { MultilineMixin } from './multilineMixin'; -import { OembedMixin } from './oembedMixin'; +import { MultilineMixin } from './multilineMixin.ts'; +import { OembedMixin } from './oembedMixin.ts'; const valueTransformationDirectory = { date: DateMixin, diff --git a/src/new-widgets/valueTransformationMixins/markdownMixin.ts b/src/new-widgets/valueTransformationMixins/markdownMixin.ts index 3e9a0478..7b2382b5 100644 --- a/src/new-widgets/valueTransformationMixins/markdownMixin.ts +++ b/src/new-widgets/valueTransformationMixins/markdownMixin.ts @@ -2,7 +2,7 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js'; import markdownit from 'markdown-it'; import mila from 'markdown-it-link-attributes'; -import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.ts'; const MarkdownMixin = { name: 'markdown-mixin', diff --git a/src/new-widgets/valueTransformationMixins/multilineMixin.ts b/src/new-widgets/valueTransformationMixins/multilineMixin.ts index 3cddca3d..c6cee1fb 100644 --- a/src/new-widgets/valueTransformationMixins/multilineMixin.ts +++ b/src/new-widgets/valueTransformationMixins/multilineMixin.ts @@ -1,5 +1,5 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js'; -import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.ts'; const MultilineMixin = { name: 'multiline-mixin', diff --git a/src/new-widgets/valueTransformationMixins/oembedMixin.ts b/src/new-widgets/valueTransformationMixins/oembedMixin.ts index c16680c6..27ad92db 100644 --- a/src/new-widgets/valueTransformationMixins/oembedMixin.ts +++ b/src/new-widgets/valueTransformationMixins/oembedMixin.ts @@ -1,5 +1,5 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js'; -import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.ts'; const OembedMixin = { name: 'oembed-mixin', diff --git a/src/widgets/baseWidget.ts b/src/widgets/baseWidget.ts index df4182e7..5c337b5f 100644 --- a/src/widgets/baseWidget.ts +++ b/src/widgets/baseWidget.ts @@ -1,5 +1,5 @@ -import { evalTemplateString } from '../libs/helpers'; -import { store } from '../libs/store/store'; +import { evalTemplateString } from '../libs/helpers.ts'; +import { store } from '../libs/store/store.ts'; export class BaseWidget extends HTMLElement { private src: string | undefined; diff --git a/src/widgets/widget-factory.ts b/src/widgets/widget-factory.ts index fad6eeb0..bf7d4222 100644 --- a/src/widgets/widget-factory.ts +++ b/src/widgets/widget-factory.ts @@ -1,5 +1,5 @@ -import { defineComponent } from '../libs/helpers'; -import { BaseWidget } from './baseWidget'; +import { defineComponent } from '../libs/helpers.ts'; +import { BaseWidget } from './baseWidget.ts'; export const widgetFactory = ( tagName: string, diff --git a/tsconfig.json b/tsconfig.json index 4c7a46b4..b1e9f0ba 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ "allowJs": true, "jsx": "preserve", "noEmit": true, + "allowImportingTsExtensions": true, "declaration": false, "declarationMap": false, "esModuleInterop": true, -- GitLab From a722f1f84bd2e6c0799c9f1195b34947886015db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Thu, 28 Nov 2024 16:53:06 +0100 Subject: [PATCH 48/66] fix: some biome rules --- biome.jsonc | 4 +++- cypress/plugins/index.js | 2 +- server.js | 4 ++-- src/mixins/sorterMixin.ts | 2 +- src/mixins/widgetMixin.ts | 2 +- src/solid-template-element.ts | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index ae1a88f0..d87081e0 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -20,7 +20,8 @@ "rules": { "recommended": true, "style": { - "noParameterAssign": "off" + "noParameterAssign": "off", + "noYodaExpression": "error" }, "complexity": { "noBannedTypes": "off" @@ -30,6 +31,7 @@ "noAsyncPromiseExecutor": "off" }, "correctness": { + "noUnusedFunctionParameters": "error", "useImportExtensions": "error" } } diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index 6a17dae1..15a942ee 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -11,4 +11,4 @@ // This function is called when a project is opened or re-opened (e.g. due to // the project's config changing) -module.exports = (on, config) => {}; +module.exports = (_on, _config) => {}; diff --git a/server.js b/server.js index c931f874..12b6244c 100644 --- a/server.js +++ b/server.js @@ -30,7 +30,7 @@ process.env.ELECTRON_EXTRA_LAUNCH_ARGS = '--lang=en'; rep.setHeader('location', `${originalUrl}/${uniqID()}.jpg`); setTimeout(() => rep.send(), 1200); }) - .get(/^\/upload\/.+/, (req, rep) => { + .get(/^\/upload\/.+/, (_req, rep) => { rep.sendFile(path.resolve('./fake-image.svg')); }) .get('/mock/users.jsonld', async (req, res) => { @@ -51,7 +51,7 @@ process.env.ELECTRON_EXTRA_LAUNCH_ARGS = '--lang=en'; res.send(data); res.end(); }) - .get('/examples/', (req, rep) => rep.redirect('/')) + .get('/examples/', (_req, rep) => rep.redirect('/')) // Listen for write requests .patch(updateURLs, handleUpdate) .post(updateURLs, handleUpdate) diff --git a/src/mixins/sorterMixin.ts b/src/mixins/sorterMixin.ts index e5cd36b3..867ff493 100644 --- a/src/mixins/sorterMixin.ts +++ b/src/mixins/sorterMixin.ts @@ -146,7 +146,7 @@ const SorterMixin = { if (this.randomOrder.length !== array.length) { // if no random order existing this.randomOrder = [...Array(array.length).keys()]; // generate array of indexes - while (0 !== currentIndex) { + while (currentIndex !== 0) { randomIndex = Math.floor(Math.random() * currentIndex); currentIndex -= 1; temporaryValue = this.randomOrder[currentIndex]; diff --git a/src/mixins/widgetMixin.ts b/src/mixins/widgetMixin.ts index 954b1ffa..3962a851 100644 --- a/src/mixins/widgetMixin.ts +++ b/src/mixins/widgetMixin.ts @@ -177,7 +177,7 @@ const WidgetMixin = { if ( typeof fieldValue === 'object' && fieldValue['@id'] && - 1 === Object.keys(fieldValue).length + Object.keys(fieldValue).length === 1 ) { return JSON.stringify([fieldValue]); } diff --git a/src/solid-template-element.ts b/src/solid-template-element.ts index 16b86cf6..1b8fe602 100644 --- a/src/solid-template-element.ts +++ b/src/solid-template-element.ts @@ -167,6 +167,6 @@ export default class SolidTemplateElement extends HTMLElement { } _camelize(str) { - return str.replace(/\W+(.)/g, (match, chr) => chr.toUpperCase()); + return str.replace(/\W+(.)/g, (_match, chr) => chr.toUpperCase()); } } -- GitLab From ebaab3407cab894dd6d59770dddc6279653a2b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Thu, 28 Nov 2024 17:01:36 +0100 Subject: [PATCH 49/66] fix `lint/suspicious/useAwait` errors --- biome.jsonc | 3 ++- src/components/solid-delete.ts | 2 +- src/components/solid-form-search.ts | 2 +- src/components/solid-member-add.ts | 2 +- src/components/solid-member-delete.ts | 2 +- src/components/solid-membership.ts | 2 +- src/components/solid-table.ts | 2 +- src/libs/filter.ts | 2 +- src/libs/store/custom-getter.ts | 2 +- src/libs/store/store.ts | 14 +++++++------- src/logger.ts | 2 +- src/mixins/attributeBinderMixin.ts | 2 +- src/mixins/serverPaginationMixin.ts | 2 +- 13 files changed, 20 insertions(+), 19 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index d87081e0..f13a6626 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -28,7 +28,8 @@ }, "suspicious": { "noExplicitAny": "off", - "noAsyncPromiseExecutor": "off" + "noAsyncPromiseExecutor": "off", + "useAwait": "error" }, "correctness": { "noUnusedFunctionParameters": "error", diff --git a/src/components/solid-delete.ts b/src/components/solid-delete.ts index bc25e3de..79661495 100644 --- a/src/components/solid-delete.ts +++ b/src/components/solid-delete.ts @@ -42,7 +42,7 @@ export const SolidDelete = { }); } }, - async delete(e: Event): Promise<void> { + delete(e: Event) { e.stopPropagation(); if (!this.dataSrc) return; this.performAction(); // In validationMixin, method defining what to do according to the present attributes diff --git a/src/components/solid-form-search.ts b/src/components/solid-form-search.ts index 86ee63b7..41505400 100644 --- a/src/components/solid-form-search.ts +++ b/src/components/solid-form-search.ts @@ -171,7 +171,7 @@ export const SolidFormSearch = { }), ); }, - async inputChange(input: EventTarget): Promise<void> { + inputChange(input: EventTarget) { // FIXME: Improve this as we need to support more than input and single select. // What about multiple select, checkboxes, radio buttons, etc? const parentElementLabel = ( diff --git a/src/components/solid-member-add.ts b/src/components/solid-member-add.ts index 90dcc5d7..75846c17 100644 --- a/src/components/solid-member-add.ts +++ b/src/components/solid-member-add.ts @@ -53,7 +53,7 @@ export const SolidMemberAdd = { }); } }, - async addMember(e: Event): Promise<void> { + addMember(e: Event) { if (!this.dataSrc || !this.resourceId) return; e.preventDefault(); this.performAction(); // In validationMixin, method defining what to do according to the present attributes diff --git a/src/components/solid-member-delete.ts b/src/components/solid-member-delete.ts index 34e7ee21..39e2f764 100644 --- a/src/components/solid-member-delete.ts +++ b/src/components/solid-member-delete.ts @@ -91,7 +91,7 @@ export const SolidMemberDelete = { }); } }, - async removeMember(e: Event): Promise<void> { + removeMember(e: Event) { e.stopPropagation(); if (!this.dataSrc) return; this.performAction(); // In validationMixin, method defining what to do according to the present attributes diff --git a/src/components/solid-membership.ts b/src/components/solid-membership.ts index 49e92b2c..af719c70 100644 --- a/src/components/solid-membership.ts +++ b/src/components/solid-membership.ts @@ -93,7 +93,7 @@ export const SolidMembership = { }); } }, - async changeMembership(e: Event): Promise<void> { + changeMembership(e: Event) { e.stopPropagation(); if (!this.dataSrc) return; this.performAction(); // In validationMixin, method defining what to do according to the present attributes diff --git a/src/components/solid-table.ts b/src/components/solid-table.ts index 65060765..c0970423 100644 --- a/src/components/solid-table.ts +++ b/src/components/solid-table.ts @@ -110,7 +110,7 @@ export const SolidTable = { * @param field * @param resource */ - async createCellWidget(field: string, resource: Resource) { + createCellWidget(field: string, resource: Resource) { // if regular widget if (!this.element.hasAttribute(`editable-${field}`)) return this.createWidgetTemplate(field, resource, true); diff --git a/src/libs/filter.ts b/src/libs/filter.ts index 093c5ff9..6fc070af 100644 --- a/src/libs/filter.ts +++ b/src/libs/filter.ts @@ -319,7 +319,7 @@ const matchFilters = async ( * @param searchForm - searchForm component * @returns resources filtered */ -const searchInResources = async ( +const searchInResources = ( resources: object[], filters: SearchQuery, fields: string, diff --git a/src/libs/store/custom-getter.ts b/src/libs/store/custom-getter.ts index b69e02c3..cc39756c 100644 --- a/src/libs/store/custom-getter.ts +++ b/src/libs/store/custom-getter.ts @@ -171,7 +171,7 @@ export class CustomGetter { iriParent: string, forceFetch = false, ): Promise<Resource | null> { - if (id.startsWith('_:b')) return store.get(id + iriParent); // anonymous node = get from cache + if (id.startsWith('_:b')) return await store.get(id + iriParent); // anonymous node = get from cache return store.getData(id, context, iriParent, undefined, forceFetch); } diff --git a/src/libs/store/store.ts b/src/libs/store/store.ts index 96658909..b17bff68 100644 --- a/src/libs/store/store.ts +++ b/src/libs/store/store.ts @@ -102,7 +102,7 @@ class Store { !this.loadingList.has(key) ) { const resource = this.get(key); - if (resource?.isFullResource?.() && !forceFetch) return resource; // if resource is not complete, re-fetch it + if (resource?.isFullResource?.() && !forceFetch) return await resource; // if resource is not complete, re-fetch it } return new Promise(async resolve => { @@ -416,7 +416,7 @@ class Store { * Notifies all components for a list of ids * @param resourceIds - */ - async notifyResources(resourceIds: string[]) { + notifyResources(resourceIds: string[]) { resourceIds = [...new Set(resourceIds)]; // remove duplicates for (const id of resourceIds) PubSub.publish(id); } @@ -426,7 +426,7 @@ class Store { * @param resource - object * @param id - string */ - async getNestedResources(resource: object, id: string) { + getNestedResources(resource: object, id: string) { const cachedResource = store.get(id); if (!cachedResource || cachedResource.isContainer?.()) return []; const nestedProperties: any[] = []; @@ -492,7 +492,7 @@ class Store { * * @returns id of the posted resource */ - async setLocalData(resource: object, id: string): Promise<string | null> { + setLocalData(resource: object, id: string): Promise<string | null> { return this._updateResource('_LOCAL', resource, id); } @@ -503,7 +503,7 @@ class Store { * * @returns id of the posted resource */ - async post(resource: object, id: string): Promise<string | null> { + post(resource: object, id: string): Promise<string | null> { return this._updateResource('POST', resource, id); } @@ -514,7 +514,7 @@ class Store { * * @returns id of the edited resource */ - async put(resource: object, id: string): Promise<string | null> { + put(resource: object, id: string): Promise<string | null> { return this._updateResource('PUT', resource, id); } @@ -525,7 +525,7 @@ class Store { * * @returns id of the edited resource */ - async patch(resource: object, id: string): Promise<string | null> { + patch(resource: object, id: string): Promise<string | null> { return this._updateResource('PATCH', resource, id); } diff --git a/src/logger.ts b/src/logger.ts index 36fbe72b..11dfd351 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -82,7 +82,7 @@ export function trackRenderAsync(fn: Function, context?: string) { // HOF to log render times and time execution export function trackRender(fn: Function, context?: string) { - return async function (...args: any[]) { + return function (...args: any[]) { let componentName = context ? context : this.name diff --git a/src/mixins/attributeBinderMixin.ts b/src/mixins/attributeBinderMixin.ts index 2a09f117..e7db4d1d 100644 --- a/src/mixins/attributeBinderMixin.ts +++ b/src/mixins/attributeBinderMixin.ts @@ -99,7 +99,7 @@ const AttributeBinderMixin = { */ async getUser() { const sibAuth: any = document.querySelector('sib-auth'); - return sibAuth.getUser(); + return await sibAuth.getUser(); }, /** diff --git a/src/mixins/serverPaginationMixin.ts b/src/mixins/serverPaginationMixin.ts index 3ac5d898..67391554 100644 --- a/src/mixins/serverPaginationMixin.ts +++ b/src/mixins/serverPaginationMixin.ts @@ -69,7 +69,7 @@ const ServerPaginationMixin = { await this.fetchData(this.dataSrc); }, - async updateNavButtons(resourceId: string, index: string, variance: number) { + updateNavButtons(resourceId: string, index: string, variance: number) { this.element.querySelector("[data-id='prev']").disabled = this.currentOffset[index] <= 0; // this.element.querySelector("[data-id='next']").disabled = await this.resource['ldp:contains'].length === 0; -- GitLab From f77fa926a26372c6ac56043ae0fda3c18bf04835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 29 Nov 2024 00:43:45 +0100 Subject: [PATCH 50/66] fix `correctness/noUnusedVariables` --- biome.jsonc | 3 ++- src/components/solid-form.ts | 4 ++-- src/libs/filter.ts | 4 ++-- src/libs/store/custom-getter.ts | 2 +- src/logger.ts | 2 +- src/mixins/widgetMixin.ts | 2 +- src/new-widgets/templatesDependencies/formCheckboxesMixin.ts | 2 +- src/new-widgets/templatesDependencies/multipleFormMixin.ts | 2 +- .../templatesDependencies/multipleselectFormMixin.ts | 2 +- src/new-widgets/valueTransformationMixins/dateMixin.ts | 2 +- src/solid-template-element.ts | 4 ++-- src/widgets/baseWidget.ts | 2 +- 12 files changed, 16 insertions(+), 15 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index f13a6626..512fa364 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -33,7 +33,8 @@ }, "correctness": { "noUnusedFunctionParameters": "error", - "useImportExtensions": "error" + "useImportExtensions": "error", + "noUnusedVariables": "error" } } }, diff --git a/src/components/solid-form.ts b/src/components/solid-form.ts index e3247089..c5c3b9e2 100644 --- a/src/components/solid-form.ts +++ b/src/components/solid-form.ts @@ -64,7 +64,7 @@ export const SolidForm = { let value = widget.component ? widget.component.getValue() : widget.value; try { value = JSON.parse(value); - } catch (e) {} + } catch {} setDeepProperty(values, name.split('.'), value); } // add @id if edition @@ -180,7 +180,7 @@ export const SolidForm = { let id: string; try { id = (await this.save()) || this.getFormValue()['@id']; - } catch (e) { + } catch (_e) { return; } this.reset(); diff --git a/src/libs/filter.ts b/src/libs/filter.ts index 6fc070af..01b2556d 100644 --- a/src/libs/filter.ts +++ b/src/libs/filter.ts @@ -265,7 +265,7 @@ const matchFilter = async ( ), ), ); - } catch (e) { + } catch { return true; } throw false; @@ -305,7 +305,7 @@ const matchFilters = async ( return match; }), ); - } catch (e) { + } catch (_e) { return false; } return true; diff --git a/src/libs/store/custom-getter.ts b/src/libs/store/custom-getter.ts index cc39756c..317b09be 100644 --- a/src/libs/store/custom-getter.ts +++ b/src/libs/store/custom-getter.ts @@ -82,7 +82,7 @@ export class CustomGetter { return result; } - } catch (e) { + } catch { if (!path.split) return undefined; // Split the path on each dots diff --git a/src/logger.ts b/src/logger.ts index 11dfd351..c392b134 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -19,7 +19,7 @@ function formatMessage(level, messages) { if (typeof msg === 'object') { try { return JSON.stringify(msg, null, 2); - } catch (error) { + } catch { return String(msg); } } diff --git a/src/mixins/widgetMixin.ts b/src/mixins/widgetMixin.ts index 3962a851..48802d8d 100644 --- a/src/mixins/widgetMixin.ts +++ b/src/mixins/widgetMixin.ts @@ -401,7 +401,7 @@ const WidgetMixin = { try { const isUrl = new URL(value); if (isUrl) attributes['data-src'] = value; - } catch (e) {} + } catch {} // in any case, set value attribute attributes.value = value; diff --git a/src/new-widgets/templatesDependencies/formCheckboxesMixin.ts b/src/new-widgets/templatesDependencies/formCheckboxesMixin.ts index 16847a69..cd175681 100644 --- a/src/new-widgets/templatesDependencies/formCheckboxesMixin.ts +++ b/src/new-widgets/templatesDependencies/formCheckboxesMixin.ts @@ -31,7 +31,7 @@ const FormCheckboxesMixin = { let value = el.value; try { value = JSON.parse(el.value); - } catch (e) {} + } catch {} return value; }); }, diff --git a/src/new-widgets/templatesDependencies/multipleFormMixin.ts b/src/new-widgets/templatesDependencies/multipleFormMixin.ts index 3b6af795..f921743f 100644 --- a/src/new-widgets/templatesDependencies/multipleFormMixin.ts +++ b/src/new-widgets/templatesDependencies/multipleFormMixin.ts @@ -78,7 +78,7 @@ const MultipleFormMixin = { if (Array.isArray(JSON.parse(value))) { this.setValue(JSON.parse(value)); } - } catch (ex) { + } catch { //FIXME: Awful trick to handle both resource @ids as value and serialized arrays values this.dataSrc = value; } diff --git a/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts b/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts index 68c1766b..c3ed64bc 100644 --- a/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts +++ b/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts @@ -53,7 +53,7 @@ const MultipleselectFormMixin = { } else { this.setValue([value]); } - } catch (ex) { + } catch { this.dataSrc = value; this.setValue([{ '@id': value }]); } diff --git a/src/new-widgets/valueTransformationMixins/dateMixin.ts b/src/new-widgets/valueTransformationMixins/dateMixin.ts index ee1ec183..5150b76d 100644 --- a/src/new-widgets/valueTransformationMixins/dateMixin.ts +++ b/src/new-widgets/valueTransformationMixins/dateMixin.ts @@ -15,7 +15,7 @@ const DateMixin = { try { // workaround for giving a specific-formatted value to the form widget this.listAttributes.originalValue = this.formatDateForInput(value); - } catch (e) { + } catch { console.warn('Invalid date format for widget', this.name); this.listAttributes.originalValue = ''; } diff --git a/src/solid-template-element.ts b/src/solid-template-element.ts index 1b8fe602..e922f2da 100644 --- a/src/solid-template-element.ts +++ b/src/solid-template-element.ts @@ -98,14 +98,14 @@ export default class SolidTemplateElement extends HTMLElement { if (result.ok) { return result .json() // parse content - .catch(e => + .catch(() => console.error( `Error while parsing the translation file: ${fullPath}`, ), ); } }) - .catch(e => + .catch(() => console.error( `Error while retrieving the translation file: ${fullPath}`, ), diff --git a/src/widgets/baseWidget.ts b/src/widgets/baseWidget.ts index 5c337b5f..79ffeabc 100644 --- a/src/widgets/baseWidget.ts +++ b/src/widgets/baseWidget.ts @@ -173,7 +173,7 @@ export class BaseWidget extends HTMLElement { try { const resourceId = resource.getChildren('ldp:contains')[index]['@id']; res = await store.getData(resourceId, this.context); - } catch (e) { + } catch { continue; } } -- GitLab From 529d33e4e1218ea4092907f7604a402813cfe1ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 29 Nov 2024 00:47:13 +0100 Subject: [PATCH 51/66] fix `style/useExplicitLengthCheck` --- biome.jsonc | 3 ++- src/libs/filter.ts | 2 +- src/libs/helpers.ts | 2 +- src/mixins/requiredMixin.ts | 4 ++-- src/mixins/widgetMixin.ts | 2 +- src/new-widgets/templatesDependencies/formFileMixin.ts | 2 +- src/new-widgets/templatesDependencies/formMixin.ts | 2 +- src/widgets/baseWidget.ts | 2 +- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index 512fa364..e21603c3 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -21,7 +21,8 @@ "recommended": true, "style": { "noParameterAssign": "off", - "noYodaExpression": "error" + "noYodaExpression": "error", + "useExplicitLengthCheck": "error" }, "complexity": { "noBannedTypes": "off" diff --git a/src/libs/filter.ts b/src/libs/filter.ts index 01b2556d..3c6decca 100644 --- a/src/libs/filter.ts +++ b/src/libs/filter.ts @@ -154,7 +154,7 @@ const traversePath = async ( let result: object[] = []; let currentRes: any; let remainingPath: string[] = path; - if (!path.length) return []; + if (path.length === 0) return []; // Split and get first item try { diff --git a/src/libs/helpers.ts b/src/libs/helpers.ts index a6eac039..c6c29cf3 100644 --- a/src/libs/helpers.ts +++ b/src/libs/helpers.ts @@ -133,7 +133,7 @@ function setDeepProperty( const name = path.shift(); if (name) { if (!(name in obj)) obj[name] = {}; - if (path.length) setDeepProperty(obj[name], path, value); + if (path.length > 0) setDeepProperty(obj[name], path, value); else obj[name] = value; } } diff --git a/src/mixins/requiredMixin.ts b/src/mixins/requiredMixin.ts index 9c560fb4..6e648cfa 100644 --- a/src/mixins/requiredMixin.ts +++ b/src/mixins/requiredMixin.ts @@ -24,7 +24,7 @@ const RequiredMixin = { : attr.name.replace('required-', ''); }); - if (requiredFields.length) { + if (requiredFields.length > 0) { for (const resource of resources) { let hasProps = true; for (const field of requiredFields) { @@ -41,7 +41,7 @@ const RequiredMixin = { const nextProcessor = listPostProcessors.shift(); if (nextProcessor) await nextProcessor( - requiredFields.length ? displays : resources, + requiredFields.length > 0 ? displays : resources, listPostProcessors, div, context, diff --git a/src/mixins/widgetMixin.ts b/src/mixins/widgetMixin.ts index 48802d8d..ca46eef7 100644 --- a/src/mixins/widgetMixin.ts +++ b/src/mixins/widgetMixin.ts @@ -480,7 +480,7 @@ const WidgetMixin = { return preHTML`<${tagName} ...=${spread(attributes)}></${tagName}>`; } } - if (!setFields.length) { + if (setFields.length === 0) { console.warn( `Set with name ${field} has not been generated due to being empty`, ); diff --git a/src/new-widgets/templatesDependencies/formFileMixin.ts b/src/new-widgets/templatesDependencies/formFileMixin.ts index 91a54df1..4699689b 100644 --- a/src/new-widgets/templatesDependencies/formFileMixin.ts +++ b/src/new-widgets/templatesDependencies/formFileMixin.ts @@ -50,7 +50,7 @@ const FormFileMixin = { } const filePicker = this.element.querySelector('input[type="file"]'); - if (filePicker.files?.length < 1) return; + if (filePicker.files?.length === 0) return; const dataHolder = this.element.querySelector('input[data-holder]'); this.listAttributes.output = 'â³'; diff --git a/src/new-widgets/templatesDependencies/formMixin.ts b/src/new-widgets/templatesDependencies/formMixin.ts index fc88faac..5c3dcbb1 100644 --- a/src/new-widgets/templatesDependencies/formMixin.ts +++ b/src/new-widgets/templatesDependencies/formMixin.ts @@ -52,7 +52,7 @@ const FormMixin = { ); }); - return widgetDataHolders.length ? widgetDataHolders : null; + return widgetDataHolders.length > 0 ? widgetDataHolders : null; }, getValueFromElement(element: any) { return element.component ? element.component.getValue() : element.value; diff --git a/src/widgets/baseWidget.ts b/src/widgets/baseWidget.ts index 79ffeabc..7120a92b 100644 --- a/src/widgets/baseWidget.ts +++ b/src/widgets/baseWidget.ts @@ -130,7 +130,7 @@ export class BaseWidget extends HTMLElement { ); }); - return widgetDataHolders.length ? widgetDataHolders : null; + return widgetDataHolders.length > 0 ? widgetDataHolders : null; } get template(): string { return ''; -- GitLab From 021a3d9b79ad8fa14b036ebadeae76cc94311f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 29 Nov 2024 08:55:34 +0100 Subject: [PATCH 52/66] biome: add some warn rules --- biome.jsonc | 15 +++++++++------ src/libs/store/store.ts | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/biome.jsonc b/biome.jsonc index e21603c3..19a07f8c 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -20,22 +20,25 @@ "rules": { "recommended": true, "style": { - "noParameterAssign": "off", + "noParameterAssign": "warn", "noYodaExpression": "error", "useExplicitLengthCheck": "error" }, "complexity": { - "noBannedTypes": "off" + "noBannedTypes": "warn", + "noExcessiveCognitiveComplexity": "warn", + "noUselessUndefinedInitialization": "warn" }, "suspicious": { - "noExplicitAny": "off", - "noAsyncPromiseExecutor": "off", + "noConsoleLog": "warn", + "noExplicitAny": "warn", + "noAsyncPromiseExecutor": "warn", "useAwait": "error" }, "correctness": { "noUnusedFunctionParameters": "error", - "useImportExtensions": "error", - "noUnusedVariables": "error" + "noUnusedVariables": "error", + "useImportExtensions": "error" } } }, diff --git a/src/libs/store/store.ts b/src/libs/store/store.ts index b17bff68..654022fe 100644 --- a/src/libs/store/store.ts +++ b/src/libs/store/store.ts @@ -253,7 +253,7 @@ class Store { // So either we do not modify the key of the blank nodes to force them into the cache // Either we modify it by adding the parentId and we end up with // a lot of cached permissions objects associated with the container top resource (like xxxxx/circles/) - const flattenedResources = await jsonld.flatten(resource); + const flattenedResources: any = await jsonld.flatten(resource); const compactedResources: any[] = await Promise.all( flattenedResources.map(r => jsonld.compact(r, {})), ); -- GitLab From 4cd37c8e95f01a7d59f6b687561892b0f09e6c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 29 Nov 2024 11:49:45 +0100 Subject: [PATCH 53/66] major: major -- GitLab From f2911e265cbf67f02388fee3de3e3e05eee66eed Mon Sep 17 00:00:00 2001 From: Anastasia Kryukova <anastasia.kryukova@protonmail.com> Date: Mon, 2 Dec 2024 12:04:01 +0100 Subject: [PATCH 54/66] Resolve "[TZCLD] Access post-processing resources from solid-display" --- examples/pagination.html | 13 ++++++++++++- src/components/solid-display.ts | 1 + src/components/solid-table.ts | 3 +++ src/mixins/federationMixin.ts | 1 + src/mixins/filterMixin.ts | 6 ++---- src/mixins/highlighterMixin.ts | 2 +- src/mixins/listMixin.ts | 1 - src/mixins/sorterMixin.ts | 1 + 8 files changed, 21 insertions(+), 7 deletions(-) diff --git a/examples/pagination.html b/examples/pagination.html index 89bb6486..18c57fc0 100644 --- a/examples/pagination.html +++ b/examples/pagination.html @@ -27,6 +27,17 @@ search-fields="email" paginate-by="2" ></solid-display> - </details> + </details> + + <details> + <summary>Search + Pagination + Order:</summary> + <solid-display + data-src="/examples/data/list/users-medium.jsonld" + fields="@id, username, first_name, last_name, email" + order-asc="first_name" + search-fields="email" + paginate-by="2" + ></solid-display> + </details> </body> </html> diff --git a/src/components/solid-display.ts b/src/components/solid-display.ts index d2641148..98e49bab 100644 --- a/src/components/solid-display.ts +++ b/src/components/solid-display.ts @@ -43,6 +43,7 @@ export const SolidDisplay = { initialState: { activeSubscription: null, removeActiveSubscription: null, + resources: [], }, created(): void { // Set route active at initialization diff --git a/src/components/solid-table.ts b/src/components/solid-table.ts index c0970423..0718f5fd 100644 --- a/src/components/solid-table.ts +++ b/src/components/solid-table.ts @@ -48,6 +48,9 @@ export const SolidTable = { default: null, }, }, + initialState: { + resources: [], + }, get parentElement(): string { return 'table'; }, diff --git a/src/mixins/federationMixin.ts b/src/mixins/federationMixin.ts index 9b1f8fbc..b4afb9ee 100644 --- a/src/mixins/federationMixin.ts +++ b/src/mixins/federationMixin.ts @@ -24,6 +24,7 @@ const FederationMixin = { let newResources: Resource[] = await this.getResources(resources); newResources = [...new Set(newResources)]; // remove possible duplicates + this.resources = [...newResources]; // Create a new array to avoid unintended reference issues const nextProcessor = listPostProcessors.shift(); if (nextProcessor) await nextProcessor(newResources, listPostProcessors, div, context); diff --git a/src/mixins/filterMixin.ts b/src/mixins/filterMixin.ts index b3b1c0ac..e4b4d4eb 100644 --- a/src/mixins/filterMixin.ts +++ b/src/mixins/filterMixin.ts @@ -105,11 +105,9 @@ const FilterMixin = { this.fields, this.searchForm, ); - this.resources = resources = resources.filter( - (_v, index) => filteredResources[index], - ); + resources = resources.filter((_v, index) => filteredResources[index]); + this.resources = [...resources]; } - const nextProcessor = listPostProcessors.shift(); if (nextProcessor) await nextProcessor( diff --git a/src/mixins/highlighterMixin.ts b/src/mixins/highlighterMixin.ts index 852d4d12..a01d321c 100644 --- a/src/mixins/highlighterMixin.ts +++ b/src/mixins/highlighterMixin.ts @@ -28,7 +28,7 @@ const HighlighterMixin = { resources = resources.map(resource => (<any>resource).proxy); // and re-transform in arra of resources } } - + this.resources = [...resources]; const nextProcessor = listPostProcessors.shift(); if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context); diff --git a/src/mixins/listMixin.ts b/src/mixins/listMixin.ts index 6492492c..77a30998 100644 --- a/src/mixins/listMixin.ts +++ b/src/mixins/listMixin.ts @@ -95,7 +95,6 @@ const ListMixin = { // Execute the first post-processor of the list const nextProcessor = listPostProcessorsCopy.shift(); - await nextProcessor( await this.resource[this.predicateName], listPostProcessorsCopy, diff --git a/src/mixins/sorterMixin.ts b/src/mixins/sorterMixin.ts index 867ff493..a565739e 100644 --- a/src/mixins/sorterMixin.ts +++ b/src/mixins/sorterMixin.ts @@ -111,6 +111,7 @@ const SorterMixin = { resources = this.shuffleResources(resources); // shuffle resources } + this.resources = [...resources]; const nextProcessor = listPostProcessors.shift(); if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context); -- GitLab From 7052ed1bb71159001e302cd903044dd3ea6ecf3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 8 Nov 2024 18:41:41 +0100 Subject: [PATCH 55/66] update tsconfig target --- tsconfig.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index b1e9f0ba..d8d76621 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,9 @@ "compilerOptions": { "target": "es2022", "module": "ESNext", - "moduleResolution": "node", + "moduleResolution": "Bundler", + "isolatedModules": true, + "moduleDetection": "force", "allowJs": true, "jsx": "preserve", "noEmit": true, -- GitLab From ae96ebac5431f8e815003188d7951d0b6f4c6c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 8 Nov 2024 18:43:05 +0100 Subject: [PATCH 56/66] remove unused tsconfig options --- tsconfig.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index d8d76621..4530729e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,11 +6,8 @@ "isolatedModules": true, "moduleDetection": "force", "allowJs": true, - "jsx": "preserve", "noEmit": true, "allowImportingTsExtensions": true, - "declaration": false, - "declarationMap": false, "esModuleInterop": true, "composite": false, "strict": true, -- GitLab From 8a7afa00f0c4685cce62b4e85455e0190921a1a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 8 Nov 2024 18:46:04 +0100 Subject: [PATCH 57/66] tsconfig: noImplicitOverride --- src/libs/lit-helpers.ts | 2 +- src/widgets/widget-factory.ts | 6 +++--- tsconfig.json | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libs/lit-helpers.ts b/src/libs/lit-helpers.ts index b3d13541..3d953992 100644 --- a/src/libs/lit-helpers.ts +++ b/src/libs/lit-helpers.ts @@ -45,7 +45,7 @@ class SpreadDirective extends Directive { return noChange; } - update(part: SpreadPartType, [spreadData]: any) { + override update(part: SpreadPartType, [spreadData]: any) { const prevData = prevCache.get(part); if (prevData === spreadData) { diff --git a/src/widgets/widget-factory.ts b/src/widgets/widget-factory.ts index bf7d4222..718433ee 100644 --- a/src/widgets/widget-factory.ts +++ b/src/widgets/widget-factory.ts @@ -10,14 +10,14 @@ export const widgetFactory = ( const registered = customElements.get(tagName); if (registered) return registered; const cls = class extends BaseWidget { - async render() { + override async render() { await super.render(); if (callback) callback(this); } - get template(): string { + override get template(): string { return customTemplate; } - get childTemplate(): string { + override get childTemplate(): string { return childTemplate; } }; diff --git a/tsconfig.json b/tsconfig.json index 4530729e..6c72f40e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,6 +13,7 @@ "strict": true, "noImplicitAny": false, "noImplicitThis": false, + "noImplicitOverride": true, "noUnusedLocals": true, "noUnusedParameters": true, "noImplicitReturns": true, -- GitLab From 821b18b81a7ba710f9a358ad2ae40fd4139ef995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 8 Nov 2024 19:07:56 +0100 Subject: [PATCH 58/66] tsconfig: verbatimModuleSyntax --- src/libs/lit-helpers.ts | 4 ++-- tsconfig.json | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/lit-helpers.ts b/src/libs/lit-helpers.ts index 3d953992..fbf334cb 100644 --- a/src/libs/lit-helpers.ts +++ b/src/libs/lit-helpers.ts @@ -16,10 +16,10 @@ import { } from 'lit'; import { - Directive, type PartInfo, - PartType, directive, + Directive, + PartType, } from 'lit/directive.js'; type SpreadPartType = diff --git a/tsconfig.json b/tsconfig.json index 6c72f40e..3a6cd9c1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,6 +18,7 @@ "noUnusedParameters": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, + "verbatimModuleSyntax": true, "resolveJsonModule": true, "baseUrl": "./", "paths": { -- GitLab From cdb8d0746980d4f8c4fdf0c05ab90b26e8400ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Sun, 10 Nov 2024 12:28:54 +0100 Subject: [PATCH 59/66] update: add add missing `@types/*` dependencies --- package-lock.json | 19 +++++++++++++++++++ package.json | 2 ++ 2 files changed, 21 insertions(+) diff --git a/package-lock.json b/package-lock.json index fb9442f6..82a51c61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,9 @@ "@biomejs/biome": "1.9.4", "@rckeller/cypress-unfetch": "^1.0.1", "@types/autolinker": "^2.0.0", + "@types/jsonld": "^1.5.15", "@types/markdown-it": "^14.1.2", + "@types/markdown-it-link-attributes": "^3.0.5", "@types/node": "^22.7.1", "@types/pubsub-js": "^1.8.6", "autolinker": "^4.0.0", @@ -987,6 +989,13 @@ "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", "dev": true }, + "node_modules/@types/jsonld": { + "version": "1.5.15", + "resolved": "https://registry.npmjs.org/@types/jsonld/-/jsonld-1.5.15.tgz", + "integrity": "sha512-PlAFPZjL+AuGYmwlqwKEL0IMP8M8RexH0NIPGfCVWSQ041H2rR/8OlyZSD7KsCVoN8vCfWdtWDBxX8yBVP+xow==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/linkify-it": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz", @@ -1003,6 +1012,16 @@ "@types/mdurl": "^2" } }, + "node_modules/@types/markdown-it-link-attributes": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@types/markdown-it-link-attributes/-/markdown-it-link-attributes-3.0.5.tgz", + "integrity": "sha512-VZ2BGN3ywUg7mBD8W6PwR8ChpOxaQSBDbLqPgvNI+uIra3zY2af1eG/3XzWTKjEraTWskMKnZqZd6m1fDF67Bg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/markdown-it": "*" + } + }, "node_modules/@types/mdurl": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-2.0.0.tgz", diff --git a/package.json b/package.json index 2e4a3428..a7b61d25 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,9 @@ "@biomejs/biome": "1.9.4", "@rckeller/cypress-unfetch": "^1.0.1", "@types/autolinker": "^2.0.0", + "@types/jsonld": "^1.5.15", "@types/markdown-it": "^14.1.2", + "@types/markdown-it-link-attributes": "^3.0.5", "@types/node": "^22.7.1", "@types/pubsub-js": "^1.8.6", "autolinker": "^4.0.0", -- GitLab From b97924b23fca0196536514c386c8015e20ca8560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Thu, 14 Nov 2024 00:08:06 +0100 Subject: [PATCH 60/66] avoid ts-ignore --- src/libs/async-query-selector-types.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libs/async-query-selector-types.ts b/src/libs/async-query-selector-types.ts index 464e1532..d6ff9d56 100644 --- a/src/libs/async-query-selector-types.ts +++ b/src/libs/async-query-selector-types.ts @@ -7,11 +7,9 @@ export type AsyncQuerySelectorType = { selectors: K, parent?: ParentNode, ): Promise<SVGElementTagNameMap[K]>; - //@ts-ignore <K extends keyof MathMLElementTagNameMap>( selectors: K, parent?: ParentNode, - //@ts-ignore ): Promise<MathMLElementTagNameMap[K]>; /** @deprecated */ <K extends keyof HTMLElementDeprecatedTagNameMap>( @@ -33,11 +31,9 @@ export type AsyncQuerySelectorAllType = { selectors: K, parent?: ParentNode, ): AsyncIterable<SVGElementTagNameMap[K]>; - //@ts-ignore <K extends keyof MathMLElementTagNameMap>( selectors: K, parent?: ParentNode, - //@ts-ignore ): AsyncIterable<MathMLElementTagNameMap[K]>; /** @deprecated */ <K extends keyof HTMLElementDeprecatedTagNameMap>( -- GitLab From da95385ce1eb80eea889b052e614d8b0554ded36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Thu, 14 Nov 2024 23:33:45 +0100 Subject: [PATCH 61/66] update remove usless `exclude` option in `tsconfig.ts` --- tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 3a6cd9c1..d98bb9cb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -28,5 +28,4 @@ "types": ["cypress"] }, "include": ["./src/**/*", "./cypress/**/*"], - "exclude": ["./node_modules/", "./cypress.config.ts"] } -- GitLab From 1783fd5abb83292ac27b9adcdea886cb66ebd710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Wed, 13 Nov 2024 13:16:12 +0100 Subject: [PATCH 62/66] improve `noImplicitAny` --- cypress/index.d.ts | 2 +- server.js | 4 +- src/components/solid-form-search.ts | 4 +- src/components/solid-form.ts | 4 +- src/components/solid-widget.ts | 1 + src/libs/Component.ts | 2 +- src/libs/ComponentFactory.ts | 8 +-- src/libs/Compositor.ts | 9 ++- src/libs/Sib.ts | 12 +--- src/libs/filter.ts | 10 ++-- src/libs/helpers.ts | 48 ++++++++-------- src/libs/lit-helpers.ts | 4 +- src/libs/store/store.ts | 2 +- src/logger.ts | 6 +- src/new-widgets/baseWidgetMixin.ts | 3 + .../callbackMixins/richtextMixin.ts | 8 +-- .../multipleselectFormMixin.ts | 7 ++- src/solid-template-element.ts | 6 +- src/solid.d.ts | 2 +- src/store.d.ts | 2 +- src/widgets/baseWidget.ts | 56 +++++++++---------- tsconfig.json | 2 +- 22 files changed, 98 insertions(+), 104 deletions(-) diff --git a/cypress/index.d.ts b/cypress/index.d.ts index b7592dd7..9e0ae69c 100644 --- a/cypress/index.d.ts +++ b/cypress/index.d.ts @@ -9,5 +9,5 @@ declare namespace Cypress { } interface Window { - sibStore: any; + sibStore: import('../src/libs/store/store').Store; } diff --git a/server.js b/server.js index 12b6244c..ce97cb81 100644 --- a/server.js +++ b/server.js @@ -75,8 +75,8 @@ process.env.ELECTRON_EXTRA_LAUNCH_ARGS = '--lang=en'; e2e: { baseUrl: addr }, }, }; - /** @type {void | CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult} */ - let test = undefined; + /** @type {void | undefined | CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult} */ + let test; try { test = process.argv.includes('--test-ui') ? await cypress.open(opt) diff --git a/src/components/solid-form-search.ts b/src/components/solid-form-search.ts index 41505400..02a30c81 100644 --- a/src/components/solid-form-search.ts +++ b/src/components/solid-form-search.ts @@ -115,12 +115,12 @@ export const SolidFormSearch = { return this.widgetFromTagName(tagName); }, - async attach(elm: any) { + async attach(elm: unknown) { if (this.attachedElements.has(elm)) return; this.attachedElements.add(elm); await this.updateAutoRanges(); }, - async detach(elm: any) { + async detach(elm: unknown) { if (!this.attachedElements.has(elm)) return; this.attachedElements.delete(elm); await this.updateAutoRanges(); diff --git a/src/components/solid-form.ts b/src/components/solid-form.ts index c5c3b9e2..b7dc1bd4 100644 --- a/src/components/solid-form.ts +++ b/src/components/solid-form.ts @@ -147,7 +147,7 @@ export const SolidForm = { this.hideError(); const resource = await this.getFormValue(); resource['@context'] = this.context; - let saved: string | null | undefined = undefined; + let saved: string | null | undefined; try { if (this.partial == null) { saved = resource['@id'] @@ -158,7 +158,7 @@ export const SolidForm = { } } catch (e: any) { this.toggleLoaderHidden(true); - if (e) { + if (e?.json) { // if server error e.json().then(error => this.showError(error)); throw e; diff --git a/src/components/solid-widget.ts b/src/components/solid-widget.ts index 0349f7c9..cad09985 100644 --- a/src/components/solid-widget.ts +++ b/src/components/solid-widget.ts @@ -52,6 +52,7 @@ export const SolidWidget = { render(await template, this.element); }, // For form widgets, handle nested solid-form + // TODO: type custom elements getValueFromElement(element: any) { if (element.tagName === 'SOLID-FORM') return element.component.value; // nested solid-form if (element.component) return element.component.getValue(); // form widget diff --git a/src/libs/Component.ts b/src/libs/Component.ts index 9d7bc242..21e4b49d 100644 --- a/src/libs/Component.ts +++ b/src/libs/Component.ts @@ -14,5 +14,5 @@ export abstract class Component implements ComponentInterface { attached() {} detached() {} - attributesCallback(_key: string, _value: any, _oldValue: any): void {} + attributesCallback(_key: string, _value: unknown, _oldValue: unknown): void {} } diff --git a/src/libs/ComponentFactory.ts b/src/libs/ComponentFactory.ts index ba1b2c9a..373cdf7e 100644 --- a/src/libs/ComponentFactory.ts +++ b/src/libs/ComponentFactory.ts @@ -44,8 +44,8 @@ export const ComponentFactory = { }, bindInitialState( componentConstructor: ComponentConstructorInterface, - initialState: object | undefined, - ): any { + initialState?: object, + ): ComponentConstructorInterface { if (initialState) { for (const key of Reflect.ownKeys(initialState)) { Reflect.defineProperty(componentConstructor.prototype, key, { @@ -60,7 +60,7 @@ export const ComponentFactory = { }, bindAttributes( componentConstructor: ComponentConstructorInterface, - attributes: AttributesDefinitionInterface | undefined, + attributes?: AttributesDefinitionInterface, ): ComponentConstructorInterface { if (attributes) { const attributesList = Reflect.ownKeys(attributes).map(key => @@ -165,7 +165,7 @@ export const ComponentFactory = { }, bindAccessors( componentConstructor: ComponentConstructorInterface, - accessors: AccessorStaticInterface, + accessors?: AccessorStaticInterface, ): ComponentConstructorInterface { if (accessors) { for (const property of Object.keys(accessors)) { diff --git a/src/libs/Compositor.ts b/src/libs/Compositor.ts index 3c9c72ae..b0a07842 100644 --- a/src/libs/Compositor.ts +++ b/src/libs/Compositor.ts @@ -59,13 +59,12 @@ export const Compositor = { return attributes; }, - mergeInitialState(mixins: MixinStaticInterface[]): any { - let initialState = {}; + mergeInitialState(mixins: MixinStaticInterface[]) { + let initialState: any = {}; for (const mixin of mixins) { - if (mixin.initialState) { - initialState = { ...mixin.initialState, ...initialState }; - } + if (!mixin.initialState) continue; + initialState = { ...mixin.initialState, ...initialState }; } return initialState; diff --git a/src/libs/Sib.ts b/src/libs/Sib.ts index 036fc9e6..2f45ac29 100644 --- a/src/libs/Sib.ts +++ b/src/libs/Sib.ts @@ -14,7 +14,7 @@ export const Sib = { }, toElement(component: ComponentConstructorInterface): typeof HTMLElement { return class extends HTMLElement { - private _component: ComponentInterface | null = null; + private component: ComponentInterface; constructor() { super(); @@ -22,16 +22,6 @@ export const Sib = { this.component.created(); } - get component(): ComponentInterface { - if (this._component === null) { - throw new Error('No component found'); - } - return this._component; - } - set component(component: ComponentInterface) { - this._component = component; - } - static get observedAttributes() { return (<any>component).observedAttributes; } diff --git a/src/libs/filter.ts b/src/libs/filter.ts index 3c6decca..755298e4 100644 --- a/src/libs/filter.ts +++ b/src/libs/filter.ts @@ -41,7 +41,7 @@ const getSetRegexp = (field: string) => { * @param searchForm - current search form * @returns true if the field is a special search field */ -const isSearchField = (field: string, searchForm: any) => { +const isSearchField = (field: string, searchForm: Element) => { return searchForm.hasAttribute(`search-${field}`); }; /** @@ -50,8 +50,8 @@ const isSearchField = (field: string, searchForm: any) => { * @param searchForm - current search form * @returns a list of fields targetted by the current search field */ -const getSearchField = (field: string, searchForm: any): string[] => { - return parseFieldsString(searchForm.getAttribute(`search-${field}`)); +const getSearchField = (field: string, searchForm: Element): string[] => { + return parseFieldsString(searchForm.getAttribute(`search-${field}`) || ''); }; /** @@ -95,7 +95,7 @@ const matchValue = async ( return orThrow(throwOn, false); } if (subject.isContainer?.()) { - let ret: any = Promise.resolve(query.value === ''); // if no query, return a match + let ret: boolean | Promise<boolean> = Promise.resolve(query.value === ''); // if no query, return a match for (const value of subject['ldp:contains']) { ret = (await ret) || (await matchValue(value, query)); // do not throw here, we need the result if (ret) return orThrow(throwOn, true); @@ -103,7 +103,7 @@ const matchValue = async ( return orThrow(throwOn, await ret); } if (Array.isArray(subject)) { - let ret: any = Promise.resolve(query.value === ''); // if no query, return a match + let ret: boolean | Promise<boolean> = Promise.resolve(query.value === ''); // if no query, return a match for (const value of subject) { ret = (await ret) || (await matchValue(value, query)); // do not throw here, we need the result if (ret) { diff --git a/src/libs/helpers.ts b/src/libs/helpers.ts index c6c29cf3..138cfc6b 100644 --- a/src/libs/helpers.ts +++ b/src/libs/helpers.ts @@ -13,7 +13,7 @@ function stringToDom(html: string): DocumentFragment { const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor; async function evalTemplateString( str: string, - variables: { [key: string]: any } = {}, + variables: { [key: string]: unknown } = {}, ) { const keys = Object.keys(variables); const values = keys.map(key => variables[key]); @@ -222,33 +222,35 @@ const compare: { [k: string]: (subject: any, query: any) => boolean } = { }, }; -function generalComparator(a, b, order = 'asc') { - let comparison = 0; - +function generalComparator( + a: unknown, + b: unknown, + order: 'asc' | 'desc' = 'asc', +): number { + if (order === 'desc') return -generalComparator(a, b); if (typeof a === 'boolean' && typeof b === 'boolean') { - comparison = a === b ? 0 : a ? 1 : -1; - } else if (!Number.isNaN(+a) && !Number.isNaN(+b)) { - comparison = Number(a) - Number(b); - } else if (Array.isArray(a) && Array.isArray(b)) { - comparison = a.length - b.length; - } else if (!Number.isNaN(Date.parse(a)) && !Number.isNaN(Date.parse(b))) { - const dateA = new Date(a); - const dateB = new Date(a); - comparison = dateA.getTime() - dateB.getTime(); - } else if (typeof a === 'object' && typeof b === 'object') { + return a === b ? 0 : a ? 1 : -1; + } + if (!Number.isNaN(Number(a)) && !Number.isNaN(Number(b))) { + return Number(a) - Number(b); + } + if (Array.isArray(a) && Array.isArray(b)) { + return a.length - b.length; + } + const dateA = Date.parse(String(a)); + const dateB = Date.parse(String(b)); + if (!Number.isNaN(dateA) && !Number.isNaN(dateB)) { + return dateA - dateB; + } + if (a instanceof Object && b instanceof Object) { const aKeys = Object.keys(a); const bKeys = Object.keys(b); - comparison = aKeys.length - bKeys.length; - } else if (a == null || b == null) { - comparison = a == null ? (b == null ? 0 : -1) : b == null ? 1 : 0; - } else { - comparison = a.toString().localeCompare(b.toString()); + return aKeys.length - bKeys.length; } - - if (order === 'desc') { - comparison = comparison * -1; + if (a == null || b == null) { + return a == null ? (b == null ? 0 : -1) : b == null ? 1 : 0; } - return comparison; + return String(a).localeCompare(String(b)); } function transformArrayToContainer(resource: object) { diff --git a/src/libs/lit-helpers.ts b/src/libs/lit-helpers.ts index fbf334cb..3d953992 100644 --- a/src/libs/lit-helpers.ts +++ b/src/libs/lit-helpers.ts @@ -16,10 +16,10 @@ import { } from 'lit'; import { - type PartInfo, - directive, Directive, + type PartInfo, PartType, + directive, } from 'lit/directive.js'; type SpreadPartType = diff --git a/src/libs/store/store.ts b/src/libs/store/store.ts index 654022fe..03342e7a 100644 --- a/src/libs/store/store.ts +++ b/src/libs/store/store.ts @@ -40,7 +40,7 @@ export const base_context = { control: 'acl:Control', }; -class Store { +export class Store { cache: Map<string, any>; subscriptionIndex: Map<string, any>; // index of all the containers per resource subscriptionVirtualContainersIndex: Map<string, any>; // index of all the containers per resource diff --git a/src/logger.ts b/src/logger.ts index c392b134..5a3f1cdb 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -9,7 +9,7 @@ const colors = { error: '\x1b[38;2;255;0;0m', // Red }; -function formatMessage(level, messages) { +function formatMessage(level: log.LogLevelNames, messages: unknown[]) { const timestamp = new Date().toISOString(); const color = colors[level] || colors.reset; @@ -48,7 +48,7 @@ if (import.meta.env?.VITE_DEBUG === 'True') { // Async HOF to log render times and time execution export function trackRenderAsync(fn: Function, context?: string) { - return async function (...args: any[]) { + return async function (...args: unknown[]) { let componentName = context ? context : this.name @@ -82,7 +82,7 @@ export function trackRenderAsync(fn: Function, context?: string) { // HOF to log render times and time execution export function trackRender(fn: Function, context?: string) { - return function (...args: any[]) { + return function (...args: unknown[]) { let componentName = context ? context : this.name diff --git a/src/new-widgets/baseWidgetMixin.ts b/src/new-widgets/baseWidgetMixin.ts index 3e8e4c3a..b93c369a 100644 --- a/src/new-widgets/baseWidgetMixin.ts +++ b/src/new-widgets/baseWidgetMixin.ts @@ -1,8 +1,11 @@ +import type PubSubType from 'pubsub-js'; import { PostProcessorRegistry } from '../libs/PostProcessorRegistry.ts'; import type { Template } from './interfaces.ts'; import { render } from 'lit'; +declare const PubSub: typeof PubSubType; + const BaseWidgetMixin = { name: 'widget-mixin', use: [], diff --git a/src/new-widgets/callbackMixins/richtextMixin.ts b/src/new-widgets/callbackMixins/richtextMixin.ts index e719f67e..22d176b0 100644 --- a/src/new-widgets/callbackMixins/richtextMixin.ts +++ b/src/new-widgets/callbackMixins/richtextMixin.ts @@ -1,6 +1,6 @@ -import Quill from 'quill'; - +//@ts-ignore import deltaMd from 'delta-markdown-for-quill'; +import Quill from 'quill'; import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.js'; import { importInlineCSS } from '../../libs/helpers.js'; @@ -106,13 +106,13 @@ const RichtextMixin = { } }, addInvalidEventListener() { - this.hiddenInput.addEventListener('invalid', e => { + (this.hiddenInput as HTMLInputElement).addEventListener('invalid', e => { e.preventDefault(); this.displayCustomErrorMessage('Please fill out this field.'); }); }, onTextChange() { - this.hiddenInput.value = this.quill.getText(); + (this.hiddenInput as HTMLInputElement).value = this.quill.getText(); this.removeErrorMessageAndStyling(); }, removeErrorMessageAndStyling() { diff --git a/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts b/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts index c3ed64bc..dce7ad4a 100644 --- a/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts +++ b/src/new-widgets/templatesDependencies/multipleselectFormMixin.ts @@ -1,4 +1,5 @@ import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.ts'; +import type { Resource } from '../../mixins/interfaces.ts'; import { StoreMixin } from '../../mixins/storeMixin.ts'; const MultipleselectFormMixin = { @@ -9,7 +10,7 @@ const MultipleselectFormMixin = { // range attribute is passed to the solid-dropdown type: String, default: '', - callback: function (value) { + callback: function (value: string) { if (value && value !== this.listAttributes.range) this.listAttributes.range = value; }, @@ -18,7 +19,7 @@ const MultipleselectFormMixin = { // enum attribute is passed to the solid-dropdown type: String, default: '', - callback: function (value) { + callback: function (value: string) { if (value && value !== this.listAttributes.enum) this.listAttributes.enum = value; }, @@ -77,7 +78,7 @@ const MultipleselectFormMixin = { this.planRender(); }, - setValue(values: string[]) { + setValue(values: Resource[]) { // set the values to the dropdown this.listAttributes.values = JSON.stringify(values.map(r => r['@id'])); }, diff --git a/src/solid-template-element.ts b/src/solid-template-element.ts index e922f2da..bf9d2560 100644 --- a/src/solid-template-element.ts +++ b/src/solid-template-element.ts @@ -5,7 +5,7 @@ export default class SolidTemplateElement extends HTMLElement { strings = {}; translationsPath = null; translationsFetched = false; - props: { [key: string]: any } = {}; + props: { [key: string]: unknown } = {}; constructor() { super(); this.initProps(); @@ -14,7 +14,7 @@ export default class SolidTemplateElement extends HTMLElement { return Object.values(SolidTemplateElement.propsDefinition); } - static get propsDefinition(): { [key: string]: any } { + static get propsDefinition(): { [key: string]: unknown } { return {}; } @@ -70,7 +70,7 @@ export default class SolidTemplateElement extends HTMLElement { */ async fetchLocaleStrings() { if (this.translationsFetched) return; - const filesToFetch: any[] = []; + const filesToFetch: unknown[] = []; if (this.translationsPath) // fetch component translations filesToFetch.push(this.fetchTranslationFile(this.translationsPath)); diff --git a/src/solid.d.ts b/src/solid.d.ts index 05f3a28a..fc9ef8f4 100644 --- a/src/solid.d.ts +++ b/src/solid.d.ts @@ -1 +1 @@ -declare let solid: any; +declare let solid: unknown; diff --git a/src/store.d.ts b/src/store.d.ts index a3a92d73..3190a1f8 100644 --- a/src/store.d.ts +++ b/src/store.d.ts @@ -1,4 +1,4 @@ -declare let sibStore: any; +declare let sibStore: import('./libs/store/store').Store; interface StoreOptions { fetchMethod?: Promise<any>; diff --git a/src/widgets/baseWidget.ts b/src/widgets/baseWidget.ts index 7120a92b..d4012623 100644 --- a/src/widgets/baseWidget.ts +++ b/src/widgets/baseWidget.ts @@ -194,39 +194,37 @@ export class BaseWidget extends HTMLElement { return resources; } - get htmlRange(): Promise<string | undefined> { - return (async () => { - let htmlRange = ''; - const rangeResources = await this.range; - if (!rangeResources) return; - for await (let element of rangeResources) { - element = await store.getData(element['@id'], this.context); // fetch the resource to display the name - this._listen(element['@id']); + async htmlRange(): Promise<string | undefined> { + let htmlRange = ''; + const rangeResources = await this.range; + if (!rangeResources) return; + for await (let element of rangeResources) { + element = await store.getData(element['@id'], this.context); // fetch the resource to display the name + this._listen(element['@id']); - let selected: boolean; - if (this._value?.isContainer?.()) { - // selected options for multiple select - selected = false; - for await (const value of this._value['ldp:contains']) { - if (value['@id'] === element['@id']) { - selected = true; - break; - } + let selected: boolean; + if (this._value?.isContainer?.()) { + // selected options for multiple select + selected = false; + for await (const value of this._value['ldp:contains']) { + if (value['@id'] === element['@id']) { + selected = true; + break; } - } else { - // selected options for simple dropdowns - selected = this._value - ? this._value['@id'] === element['@id'] - : false; } - htmlRange += await evalTemplateString(this.childTemplate, { - name: await element.name, - id: element['@id'], - selected: selected, - }); + } else { + // selected options for simple dropdowns + selected = this._value + ? this._value['@id'] === element['@id'] + : false; } - return htmlRange || ''; - })(); + htmlRange += await evalTemplateString(this.childTemplate, { + name: await element.name, + id: element['@id'], + selected: selected, + }); + } + return htmlRange || ''; } getValueHolder(element) { return element.component ? element.component : element; diff --git a/tsconfig.json b/tsconfig.json index d98bb9cb..6d6b34a6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -27,5 +27,5 @@ "skipLibCheck": true, "types": ["cypress"] }, - "include": ["./src/**/*", "./cypress/**/*"], + "include": ["./src/**/*", "./cypress/**/*"] } -- GitLab From 6cb9cf7ece1aa98deafe75bfe48daf9e11863498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Tue, 3 Dec 2024 09:32:03 +0100 Subject: [PATCH 63/66] fix: tests --- cypress/e2e/e2e/solid-table.cy.ts | 20 +++++++++++++++++++- examples/e2e/solid-table.html | 9 +++++++++ src/libs/helpers.ts | 11 ++++++----- src/widgets/baseWidget.ts | 4 +--- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/cypress/e2e/e2e/solid-table.cy.ts b/cypress/e2e/e2e/solid-table.cy.ts index 46b23dc4..5cd5789f 100644 --- a/cypress/e2e/e2e/solid-table.cy.ts +++ b/cypress/e2e/e2e/solid-table.cy.ts @@ -329,7 +329,7 @@ describe('solid-table', { testIsolation: false }, function () { }); }); - cy.get('#grouped-table-date-asc').within(() => { + cy.get('#grouped-table-date-desc').within(() => { cy.get('solid-group-default').should('have.length', 4); cy.get('solid-group-default').each((item, index) => { if (index === 0) { @@ -346,5 +346,23 @@ describe('solid-table', { testIsolation: false }, function () { } }); }); + + cy.get('#grouped-table-date-asc').within(() => { + cy.get('solid-group-default').should('have.length', 4); + cy.get('solid-group-default').each((item, index) => { + if (index === 0) { + cy.wrap(item).find('span').contains('2015-05-10'); + } + if (index === 1) { + cy.wrap(item).find('span').contains('2017-05-10'); + } + if (index === 2) { + cy.wrap(item).find('span').contains('2020-05-10'); + } + if (index === 3) { + cy.wrap(item).find('span').contains('2020-07-09'); + } + }); + }); }); }); diff --git a/examples/e2e/solid-table.html b/examples/e2e/solid-table.html index 4b3ed9a3..f377f69b 100644 --- a/examples/e2e/solid-table.html +++ b/examples/e2e/solid-table.html @@ -93,6 +93,15 @@ order-group-asc ></solid-table> + <h4>Table grouped by desc date</h4> + <solid-table + id="grouped-table-date-desc" + data-src="/examples/data/list/event-5.jsonld" + fields="name, date, place, year" + group-by="date" + order-group-desc + ></solid-table> + <h4>Table grouped by asc date</h4> <solid-table id="grouped-table-date-asc" diff --git a/src/libs/helpers.ts b/src/libs/helpers.ts index 138cfc6b..adf004ef 100644 --- a/src/libs/helpers.ts +++ b/src/libs/helpers.ts @@ -227,7 +227,9 @@ function generalComparator( b: unknown, order: 'asc' | 'desc' = 'asc', ): number { - if (order === 'desc') return -generalComparator(a, b); + if (order === 'desc') return generalComparator(b, a); + if (a == null && b == null) return 0; + if (a === b || Object.is(a, b)) return 0; if (typeof a === 'boolean' && typeof b === 'boolean') { return a === b ? 0 : a ? 1 : -1; } @@ -242,14 +244,13 @@ function generalComparator( if (!Number.isNaN(dateA) && !Number.isNaN(dateB)) { return dateA - dateB; } - if (a instanceof Object && b instanceof Object) { + if (a && b && typeof a === 'object' && typeof b === 'object') { const aKeys = Object.keys(a); const bKeys = Object.keys(b); return aKeys.length - bKeys.length; } - if (a == null || b == null) { - return a == null ? (b == null ? 0 : -1) : b == null ? 1 : 0; - } + if (a == null) return -1; + if (b == null) return 1; return String(a).localeCompare(String(b)); } diff --git a/src/widgets/baseWidget.ts b/src/widgets/baseWidget.ts index d4012623..50553b82 100644 --- a/src/widgets/baseWidget.ts +++ b/src/widgets/baseWidget.ts @@ -214,9 +214,7 @@ export class BaseWidget extends HTMLElement { } } else { // selected options for simple dropdowns - selected = this._value - ? this._value['@id'] === element['@id'] - : false; + selected = this._value ? this._value['@id'] === element['@id'] : false; } htmlRange += await evalTemplateString(this.childTemplate, { name: await element.name, -- GitLab From c2381f89b2c7d5b3248f385b29c8128dbc670456 Mon Sep 17 00:00:00 2001 From: Anastasia Kryukova <anastasia.kryukova@protonmail.com> Date: Wed, 20 Nov 2024 19:23:08 +0100 Subject: [PATCH 64/66] fix: mulitple new line issue add: tests quotes format fix lint fix: richtext multiline issue --- cypress/e2e/e2e/solid-form-richtext.cy.ts | 7 + examples/data/list/event-6.jsonld | 12 + examples/e2e/solid-form-richtext.html | 8 + package-lock.json | 223 +----------------- package.json | 8 +- .../callbackMixins/richtextMixin.ts | 15 +- 6 files changed, 47 insertions(+), 226 deletions(-) create mode 100644 examples/data/list/event-6.jsonld diff --git a/cypress/e2e/e2e/solid-form-richtext.cy.ts b/cypress/e2e/e2e/solid-form-richtext.cy.ts index 8ede29d4..3643f68f 100644 --- a/cypress/e2e/e2e/solid-form-richtext.cy.ts +++ b/cypress/e2e/e2e/solid-form-richtext.cy.ts @@ -111,4 +111,11 @@ describe('solid-form-richtext test', function () { .should('have.attr', 'href', 'http://drawing.garden/') .and('contain', 'my site'); }); + + it('Editor displays correctly multiple new lines', () => { + cy.get('#form-5 div[data-richtext] [contenteditable]').should( + 'have.html', + '<p>Première ligne</p><p><br></p><p><br></p><p><br></p><p>Seconde Ligne avec quatre sauts de ligne</p>', + ); + }); }); diff --git a/examples/data/list/event-6.jsonld b/examples/data/list/event-6.jsonld new file mode 100644 index 00000000..9a36c477 --- /dev/null +++ b/examples/data/list/event-6.jsonld @@ -0,0 +1,12 @@ +{ + "@id": "/examples/data/list/event-6.jsonld", + "name": "Coliving", + "date": "2020-07-09", + "seats": 12, + "description": "Première ligne\r\n\r\n\r\n\r\nSeconde Ligne avec quatre sauts de ligne", + "contact": { + "@id": "/examples/data/list/user-1.jsonld" + }, + "permissions": [], + "@context": "https://cdn.startinblox.com/owl/context.jsonld" +} diff --git a/examples/e2e/solid-form-richtext.html b/examples/e2e/solid-form-richtext.html index fe111ed4..ab4266e0 100644 --- a/examples/e2e/solid-form-richtext.html +++ b/examples/e2e/solid-form-richtext.html @@ -47,6 +47,14 @@ widget-website="solid-form-richtext" ></solid-form> + <h3>multiple new lines</h3> + <solid-form + id="form-5" + data-src="/examples/data/list/event-6.jsonld" + fields="description" + widget-description="solid-form-richtext"> + </solid-form> + <style> .id { font-family: monospace; diff --git a/package-lock.json b/package-lock.json index fb9442f6..b9b9f565 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,6 @@ "autolinker": "^4.0.0", "cypress": "^13.14.2", "cypress-plugin-tab": "^1.0.5", - "delta-markdown-for-quill": "0.0.9", "dialog-polyfill": "^0.5.6", "express": "^4.21.0", "find-free-port": "^2.0.0", @@ -33,7 +32,7 @@ "markdown-it": "^14.1.0", "markdown-it-link-attributes": "4.0.1", "pubsub-js": "^1.9.4", - "quill": "^2.0.2", + "quill": "^2.0.3", "quill-delta-to-markdown": "^0.6.0", "semver": "7.6.3", "slim-select": "^2.9.2", @@ -1523,24 +1522,6 @@ "node": ">=4.0.0" } }, - "node_modules/commonmark": { - "version": "0.26.0", - "resolved": "https://registry.npmjs.org/commonmark/-/commonmark-0.26.0.tgz", - "integrity": "sha512-0PvjGTgkIjIdImgpt1xgR049Nyz/x27vhYT+C0ZkNuxEiys/lJZKotOVKa4y7JbtMsTutg/gCLH+13DFnaOjWg==", - "dev": true, - "dependencies": { - "entities": "~ 1.1.1", - "mdurl": "~ 1.0.1", - "minimist": "~ 1.2.0", - "string.prototype.repeat": "^0.2.0" - }, - "bin": { - "commonmark": "bin/commonmark" - }, - "engines": { - "node": "*" - } - }, "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -1820,23 +1801,6 @@ } } }, - "node_modules/deep-equal": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.1.1.tgz", - "integrity": "sha512-yd9c5AdiqVcR+JjcwUQb9DkhJc8ngNr0MahEBGvDiJw8puWab2yZlh+nkasOnZP+EGTAP6rRp2JzJhJZzvNF8g==", - "dev": true, - "dependencies": { - "is-arguments": "^1.0.4", - "is-date-object": "^1.0.1", - "is-regex": "^1.0.4", - "object-is": "^1.0.1", - "object-keys": "^1.1.1", - "regexp.prototype.flags": "^1.2.0" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/define-data-property": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", @@ -1854,23 +1818,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/define-properties": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", - "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", - "dev": true, - "dependencies": { - "define-data-property": "^1.0.1", - "has-property-descriptors": "^1.0.0", - "object-keys": "^1.1.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -1880,37 +1827,6 @@ "node": ">=0.4.0" } }, - "node_modules/delta-markdown-for-quill": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/delta-markdown-for-quill/-/delta-markdown-for-quill-0.0.9.tgz", - "integrity": "sha512-Pb6LjAey0I1N5od660V3cisq7XBRK1VOS7ctJbm6z98fNRj1w6Kd0HT8Boqvsue42FfQ0+6UVfwFXyug8THKLA==", - "dev": true, - "dependencies": { - "commonmark": "^0.26.0", - "lodash": "^4.16.4", - "quill-delta": "^3.4.0" - } - }, - "node_modules/delta-markdown-for-quill/node_modules/fast-diff": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.1.2.tgz", - "integrity": "sha512-KaJUt+M9t1qaIteSvjc6P3RbMdXsNhK61GRftR6SNxqmhthcd9MGIi4T+o0jD8LUSpSnSKXE20nLtJ3fOHxQig==", - "dev": true - }, - "node_modules/delta-markdown-for-quill/node_modules/quill-delta": { - "version": "3.6.3", - "resolved": "https://registry.npmjs.org/quill-delta/-/quill-delta-3.6.3.tgz", - "integrity": "sha512-wdIGBlcX13tCHOXGMVnnTVFtGRLoP0imqxM696fIPwIf5ODIYUHIvHbZcyvGlZFiFhK5XzDC2lpjbxRhnM05Tg==", - "dev": true, - "dependencies": { - "deep-equal": "^1.0.1", - "extend": "^3.0.2", - "fast-diff": "1.1.2" - }, - "engines": { - "node": ">=0.10" - } - }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -2010,12 +1926,6 @@ "node": ">=8.6" } }, - "node_modules/entities": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", - "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==", - "dev": true - }, "node_modules/es-define-property": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", @@ -2424,15 +2334,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/functions-have-names": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", - "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", - "dev": true, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/fuse.js": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-7.0.0.tgz", @@ -2563,21 +2464,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/has-tostringtag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", - "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", - "dev": true, - "dependencies": { - "has-symbols": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/hasown": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", @@ -2694,37 +2580,6 @@ "node": ">= 0.10" } }, - "node_modules/is-arguments": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", - "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-date-object": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz", - "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", - "dev": true, - "dependencies": { - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -2759,22 +2614,6 @@ "node": ">=8" } }, - "node_modules/is-regex": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", - "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-stream": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", @@ -3291,12 +3130,6 @@ "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", "dev": true }, - "node_modules/mdurl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", - "integrity": "sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==", - "dev": true - }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -3484,31 +3317,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/object-is": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz", - "integrity": "sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "dev": true, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/on-finished": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", @@ -3732,9 +3540,9 @@ } }, "node_modules/quill": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/quill/-/quill-2.0.2.tgz", - "integrity": "sha512-QfazNrhMakEdRG57IoYFwffUIr04LWJxbS/ZkidRFXYCQt63c1gK6Z7IHUXMx/Vh25WgPBU42oBaNzQ0K1R/xw==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/quill/-/quill-2.0.3.tgz", + "integrity": "sha512-xEYQBqfYx/sfb33VJiKnSJp8ehloavImQ2A6564GAbqG55PGw1dAWUn1MUbQB62t0azawUS2CZZhWCjO8gRvTw==", "dev": true, "dependencies": { "eventemitter3": "^5.0.1", @@ -3820,23 +3628,6 @@ "node": ">=12" } }, - "node_modules/regexp.prototype.flags": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.0.tgz", - "integrity": "sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.2.0", - "functions-have-names": "^1.2.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/relative-to-absolute-iri": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/relative-to-absolute-iri/-/relative-to-absolute-iri-1.0.7.tgz", @@ -4231,12 +4022,6 @@ "node": ">=8" } }, - "node_modules/string.prototype.repeat": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/string.prototype.repeat/-/string.prototype.repeat-0.2.0.tgz", - "integrity": "sha512-1BH+X+1hSthZFW+X+JaUkjkkUPwIlLEMJBLANN3hOob3RhEk5snLWNECDnYbgn/m5c5JV7Ersu1Yubaf+05cIA==", - "dev": true - }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", diff --git a/package.json b/package.json index 2e4a3428..3b4b4ae9 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,10 @@ "directories": { "example": "examples" }, - "files": ["dist", "doc"], + "files": [ + "dist", + "doc" + ], "scripts": { "build": "vite build", "watch": "vite build --watch --sourcemap 'inline'", @@ -73,7 +76,6 @@ "autolinker": "^4.0.0", "cypress": "^13.14.2", "cypress-plugin-tab": "^1.0.5", - "delta-markdown-for-quill": "0.0.9", "dialog-polyfill": "^0.5.6", "express": "^4.21.0", "find-free-port": "^2.0.0", @@ -83,7 +85,7 @@ "markdown-it": "^14.1.0", "markdown-it-link-attributes": "4.0.1", "pubsub-js": "^1.9.4", - "quill": "^2.0.2", + "quill": "^2.0.3", "quill-delta-to-markdown": "^0.6.0", "semver": "7.6.3", "slim-select": "^2.9.2", diff --git a/src/new-widgets/callbackMixins/richtextMixin.ts b/src/new-widgets/callbackMixins/richtextMixin.ts index e719f67e..6ca9920f 100644 --- a/src/new-widgets/callbackMixins/richtextMixin.ts +++ b/src/new-widgets/callbackMixins/richtextMixin.ts @@ -1,8 +1,8 @@ import Quill from 'quill'; -import deltaMd from 'delta-markdown-for-quill'; -import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.js'; +import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.js'; import { importInlineCSS } from '../../libs/helpers.js'; +import MarkdownIt from 'markdown-it'; const RichtextMixin = { name: 'richtext-mixin', @@ -44,8 +44,15 @@ const RichtextMixin = { }); } - const ops = deltaMd.toDelta(this.value); - this.quill.setContents(ops); + const mdParser = new MarkdownIt({ + html: true, + }); + + const formattedValue = this.value.replace(/\r\n|\n/g, '<br>'); + const html = mdParser.render(formattedValue); // Convert Markdown to HTML + const delta = this.quill.clipboard.convert({ html }); // Convert HTML to Delta + + this.quill.setContents(delta); if (this.isRequired()) { this.createHiddenRequiredInput(); this.quill.on('text-change', this.onTextChange.bind(this)); -- GitLab From 97f538539708268fe372d2ebbfd276ac382481f4 Mon Sep 17 00:00:00 2001 From: Anastasia Kryukova <anastasia.kryukova@protonmail.com> Date: Tue, 3 Dec 2024 10:44:32 +0100 Subject: [PATCH 65/66] fix lint --- package.json | 5 +---- server.js | 4 ++-- src/components/solid-form.ts | 2 +- src/new-widgets/callbackMixins/richtextMixin.ts | 4 ++-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 3b4b4ae9..706bd1b2 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,7 @@ "directories": { "example": "examples" }, - "files": [ - "dist", - "doc" - ], + "files": ["dist", "doc"], "scripts": { "build": "vite build", "watch": "vite build --watch --sourcemap 'inline'", diff --git a/server.js b/server.js index 12b6244c..009775d9 100644 --- a/server.js +++ b/server.js @@ -75,8 +75,8 @@ process.env.ELECTRON_EXTRA_LAUNCH_ARGS = '--lang=en'; e2e: { baseUrl: addr }, }, }; - /** @type {void | CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult} */ - let test = undefined; + /** @type {null | void | CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult} */ + let test = null; try { test = process.argv.includes('--test-ui') ? await cypress.open(opt) diff --git a/src/components/solid-form.ts b/src/components/solid-form.ts index c5c3b9e2..a07e4e5c 100644 --- a/src/components/solid-form.ts +++ b/src/components/solid-form.ts @@ -147,7 +147,7 @@ export const SolidForm = { this.hideError(); const resource = await this.getFormValue(); resource['@context'] = this.context; - let saved: string | null | undefined = undefined; + let saved: string | null | undefined; try { if (this.partial == null) { saved = resource['@id'] diff --git a/src/new-widgets/callbackMixins/richtextMixin.ts b/src/new-widgets/callbackMixins/richtextMixin.ts index 6ca9920f..e3b671ae 100644 --- a/src/new-widgets/callbackMixins/richtextMixin.ts +++ b/src/new-widgets/callbackMixins/richtextMixin.ts @@ -1,8 +1,8 @@ import Quill from 'quill'; -import { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.js'; -import { importInlineCSS } from '../../libs/helpers.js'; import MarkdownIt from 'markdown-it'; +import type { PostProcessorRegistry } from '../../libs/PostProcessorRegistry.js'; +import { importInlineCSS } from '../../libs/helpers.js'; const RichtextMixin = { name: 'richtext-mixin', -- GitLab From 21ecfa79f28b9346c5968e43c750c6f510d983fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Tue, 3 Dec 2024 17:17:38 +0100 Subject: [PATCH 66/66] update: only check lint errors --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 88ff350f..c50bd545 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,9 @@ "build": "vite build", "watch": "vite build --watch --sourcemap 'inline'", "serve": "node --watch server.js", - "lint": "biome check", - "lint:fix": "biome check --write", + "lint": "biome check --diagnostic-level=error", + "lint-all": "biome check", + "lint-fix": "biome check --write", "check-types": "tsc", "test": "node server.js --test", "cypress": "node server.js --test-ui", -- GitLab