From aeeedcd70058a73f1a00da0d12f2a555ab5d5cf0 Mon Sep 17 00:00:00 2001 From: Xavier Rutayisire Date: Wed, 28 Aug 2024 20:14:07 +0200 Subject: [PATCH 01/11] feat: support link text --- examples/with-typescript/index.tsx | 5 +- examples/with-typescript/package.json | 2 +- package-lock.json | 378 ++------------------- package.json | 8 +- src/react-server/PrismicLink.tsx | 22 +- test/PrismicLink.test.tsx | 47 +++ test/react-server/PrismicRichText.test.tsx | 21 ++ 7 files changed, 132 insertions(+), 351 deletions(-) diff --git a/examples/with-typescript/index.tsx b/examples/with-typescript/index.tsx index 9031758..d2bd188 100644 --- a/examples/with-typescript/index.tsx +++ b/examples/with-typescript/index.tsx @@ -7,7 +7,6 @@ type PageDocument = prismic.PrismicDocumentWithUID<{ title: prismic.TitleField; meta_description: prismic.RichTextField; related_links: prismic.GroupField<{ - label: prismic.KeyTextField; link: prismic.LinkField; }>; @@ -23,7 +22,6 @@ type PageDocument = prismic.PrismicDocumentWithUID<{ heading: prismic.KeyTextField; body: prismic.RichTextField; buttons: prismic.GroupField<{ - label: prismic.KeyTextField; link: prismic.LinkField; }>; } @@ -38,7 +36,6 @@ type PageDocument = prismic.PrismicDocumentWithUID<{ { text: prismic.RichTextField; buttons: prismic.GroupField<{ - label: prismic.KeyTextField; link: prismic.LinkField; }>; } @@ -85,7 +82,7 @@ export const WithGroupFieldLink = (): JSX.Element => { : item.link.url } > - {item.label} + ), )} diff --git a/examples/with-typescript/package.json b/examples/with-typescript/package.json index 4121184..cc75ce7 100644 --- a/examples/with-typescript/package.json +++ b/examples/with-typescript/package.json @@ -4,6 +4,6 @@ "@prismicio/react": "../../src" }, "devDependencies": { - "@prismicio/client": "^7.5.0" + "@prismicio/client": "7.9.0-alpha.2" } } diff --git a/package-lock.json b/package-lock.json index e3e6699..7117e15 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,8 +12,8 @@ "@prismicio/richtext": "^2.1.5" }, "devDependencies": { - "@prismicio/client": "^7.1.0", - "@prismicio/mock": "^0.3.1", + "@prismicio/client": "7.9.0-alpha.2", + "@prismicio/mock": "0.3.8-alpha.0", "@size-limit/preset-small-lib": "^8.2.4", "@testing-library/react": "^14.0.0", "@types/node-fetch": "^3.0.3", @@ -1156,28 +1156,29 @@ "dev": true }, "node_modules/@prismicio/client": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/@prismicio/client/-/client-7.1.0.tgz", - "integrity": "sha512-9UvPjPae+7KfdZpUvdDCQG+9GCrR/A0BVFrixj1O7lv7SCJuyp50ZIVm9cc6G49E0HMSHFH592isRKj/xKjP+w==", + "version": "7.9.0-alpha.2", + "resolved": "https://registry.npmjs.org/@prismicio/client/-/client-7.9.0-alpha.2.tgz", + "integrity": "sha512-Y4Ti7XoJ57Rk2AkhI0UBxg3f2+wGr4ZwGfr82bFbmY9CCAUXQ+aN8cl3nUSCUafhRyJTcqWSty52D8RKvseY4g==", "dev": true, + "license": "Apache-2.0", "dependencies": { - "@prismicio/richtext": "^2.1.5", - "imgix-url-builder": "^0.0.3" + "imgix-url-builder": "^0.0.5" }, "engines": { "node": ">=14.15.0" } }, "node_modules/@prismicio/mock": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@prismicio/mock/-/mock-0.3.1.tgz", - "integrity": "sha512-xwwnQ6kKfHMypjao2Q0sdUFuQsdDlif8qmgKoqYv8KlmNxKHzurgfGh9Zl1wHF1ldEJ8C3NVpI4AqdaHjyCHSA==", + "version": "0.3.8-alpha.0", + "resolved": "https://registry.npmjs.org/@prismicio/mock/-/mock-0.3.8-alpha.0.tgz", + "integrity": "sha512-w8yGiL6cmapktjeb47IS4zdqFArfo+cC81ahdoDBShOjREqQjzTHECihMudcnePav5Ok11IUHXB0F5Il3aaRjA==", "dev": true, + "license": "Apache-2.0", "dependencies": { - "change-case": "^4.1.2" + "change-case": "^5.4.4" }, "engines": { - "node": ">=12.7.0" + "node": ">=18" }, "peerDependencies": { "@prismicio/client": "^7" @@ -2273,16 +2274,6 @@ "node": ">=6" } }, - "node_modules/camel-case": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", - "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", - "dev": true, - "dependencies": { - "pascal-case": "^3.1.2", - "tslib": "^2.0.3" - } - }, "node_modules/camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", @@ -2329,17 +2320,6 @@ } ] }, - "node_modules/capital-case": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/capital-case/-/capital-case-1.0.4.tgz", - "integrity": "sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A==", - "dev": true, - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case-first": "^2.0.2" - } - }, "node_modules/chai": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz", @@ -2375,24 +2355,11 @@ } }, "node_modules/change-case": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/change-case/-/change-case-4.1.2.tgz", - "integrity": "sha512-bSxY2ws9OtviILG1EiY5K7NNxkqg/JnRnFxLtKQ96JaviiIxi7djMrSd0ECT9AC+lttClmYwKw53BWpOMblo7A==", + "version": "5.4.4", + "resolved": "https://registry.npmjs.org/change-case/-/change-case-5.4.4.tgz", + "integrity": "sha512-HRQyTk2/YPEkt9TnUPbOpr64Uw3KOicFWPVBb+xiHvd6eBx/qPr9xqfBFDT8P2vWsvvz4jbEkfDe71W3VyNu2w==", "dev": true, - "dependencies": { - "camel-case": "^4.1.2", - "capital-case": "^1.0.4", - "constant-case": "^3.0.4", - "dot-case": "^3.0.4", - "header-case": "^2.0.4", - "no-case": "^3.0.4", - "param-case": "^3.0.4", - "pascal-case": "^3.1.2", - "path-case": "^3.0.4", - "sentence-case": "^3.0.4", - "snake-case": "^3.0.4", - "tslib": "^2.0.3" - } + "license": "MIT" }, "node_modules/character-entities": { "version": "2.0.2", @@ -2588,17 +2555,6 @@ "node": ">=10.18.0 <11 || >=12.14.0 <13 || >=14" } }, - "node_modules/constant-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/constant-case/-/constant-case-3.0.4.tgz", - "integrity": "sha512-I2hSBi7Vvs7BEuJDr5dDHfzb/Ruj3FyvFyh7KLilAjNQw3Be+xgqUBA2W6scVEcL0hL1dwPRtIqEPVUCKkSsyQ==", - "dev": true, - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case": "^2.0.2" - } - }, "node_modules/conventional-changelog": { "version": "3.1.25", "resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-3.1.25.tgz", @@ -3156,16 +3112,6 @@ "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", "dev": true }, - "node_modules/dot-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", - "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", - "dev": true, - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/dot-prop": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", @@ -4480,16 +4426,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/header-case": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/header-case/-/header-case-2.0.4.tgz", - "integrity": "sha512-H/vuk5TEEVZwrR0lp2zed9OCo1uAILMlx0JEMgC26rzyJJ3N1v6XkwHHXJQdR2doSjcGPM6OKPYoJgf0plJ11Q==", - "dev": true, - "dependencies": { - "capital-case": "^1.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/headers-polyfill": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/headers-polyfill/-/headers-polyfill-3.1.2.tgz", @@ -4574,10 +4510,11 @@ } }, "node_modules/imgix-url-builder": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/imgix-url-builder/-/imgix-url-builder-0.0.3.tgz", - "integrity": "sha512-8Oc2Cn4+jF06sEfJcVPlWYfD2F6RjrwIMbk1xEzux8unoB5LsvFc/GL1BQ47HPaeE12ReX2nMUcjUslGYWLxHA==", + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/imgix-url-builder/-/imgix-url-builder-0.0.5.tgz", + "integrity": "sha512-dCx3UlXghtsjySoqVCcHQHRikqDummwQEfKlxBUK/wrMzd+1ox/XX+zhqVuXKMVuZvCc84pVLEJyntQB0OOi/w==", "dev": true, + "license": "Apache-2.0", "engines": { "node": ">=12.7.0" } @@ -5444,15 +5381,6 @@ "get-func-name": "^2.0.0" } }, - "node_modules/lower-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", - "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", - "dev": true, - "dependencies": { - "tslib": "^2.0.3" - } - }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -6519,16 +6447,6 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, - "node_modules/no-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", - "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", - "dev": true, - "dependencies": { - "lower-case": "^2.0.2", - "tslib": "^2.0.3" - } - }, "node_modules/node-domexception": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", @@ -6836,16 +6754,6 @@ "node": ">=6" } }, - "node_modules/param-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", - "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==", - "dev": true, - "dependencies": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -6871,26 +6779,6 @@ "node": ">=4" } }, - "node_modules/pascal-case": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", - "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", - "dev": true, - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/path-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/path-case/-/path-case-3.0.4.tgz", - "integrity": "sha512-qO4qCFjXqVTrcbPt/hQfhTQ+VhFsqNKOPtytgNKkKxSoEp3XPUQ8ObFuePylOIok5gjn69ry8XiULxCwot3Wfg==", - "dev": true, - "dependencies": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -7700,17 +7588,6 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, - "node_modules/sentence-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/sentence-case/-/sentence-case-3.0.4.tgz", - "integrity": "sha512-8LS0JInaQMCRoQ7YUytAo/xUu5W2XnQxV2HI/6uM6U7CITS1RqPElr30V6uIqyMKM9lJGRVFy5/4CuzcixNYSg==", - "dev": true, - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case-first": "^2.0.2" - } - }, "node_modules/set-cookie-parser": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.6.0.tgz", @@ -7793,16 +7670,6 @@ "node": ">=8" } }, - "node_modules/snake-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz", - "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==", - "dev": true, - "dependencies": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -8474,24 +8341,6 @@ "browserslist": ">= 4.21.0" } }, - "node_modules/upper-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-2.0.2.tgz", - "integrity": "sha512-KgdgDGJt2TpuwBUIjgG6lzw2GWFRCW9Qkfkiv0DxqHHLYJHmtmdUIKcZd8rHgFSjopVTlw6ggzCm1b8MFQwikg==", - "dev": true, - "dependencies": { - "tslib": "^2.0.3" - } - }, - "node_modules/upper-case-first": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/upper-case-first/-/upper-case-first-2.0.2.tgz", - "integrity": "sha512-514ppYHBaKwfJRK/pNC6c/OxfGa0obSnAl106u97Ed0I625Nin96KAjttZF6ZL3e1XLtphxnqrOi9iWgm+u+bg==", - "dev": true, - "dependencies": { - "tslib": "^2.0.3" - } - }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -9752,22 +9601,21 @@ "dev": true }, "@prismicio/client": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/@prismicio/client/-/client-7.1.0.tgz", - "integrity": "sha512-9UvPjPae+7KfdZpUvdDCQG+9GCrR/A0BVFrixj1O7lv7SCJuyp50ZIVm9cc6G49E0HMSHFH592isRKj/xKjP+w==", + "version": "7.9.0-alpha.2", + "resolved": "https://registry.npmjs.org/@prismicio/client/-/client-7.9.0-alpha.2.tgz", + "integrity": "sha512-Y4Ti7XoJ57Rk2AkhI0UBxg3f2+wGr4ZwGfr82bFbmY9CCAUXQ+aN8cl3nUSCUafhRyJTcqWSty52D8RKvseY4g==", "dev": true, "requires": { - "@prismicio/richtext": "^2.1.5", - "imgix-url-builder": "^0.0.3" + "imgix-url-builder": "^0.0.5" } }, "@prismicio/mock": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@prismicio/mock/-/mock-0.3.1.tgz", - "integrity": "sha512-xwwnQ6kKfHMypjao2Q0sdUFuQsdDlif8qmgKoqYv8KlmNxKHzurgfGh9Zl1wHF1ldEJ8C3NVpI4AqdaHjyCHSA==", + "version": "0.3.8-alpha.0", + "resolved": "https://registry.npmjs.org/@prismicio/mock/-/mock-0.3.8-alpha.0.tgz", + "integrity": "sha512-w8yGiL6cmapktjeb47IS4zdqFArfo+cC81ahdoDBShOjREqQjzTHECihMudcnePav5Ok11IUHXB0F5Il3aaRjA==", "dev": true, "requires": { - "change-case": "^4.1.2" + "change-case": "^5.4.4" } }, "@prismicio/richtext": { @@ -10539,16 +10387,6 @@ "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true }, - "camel-case": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", - "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", - "dev": true, - "requires": { - "pascal-case": "^3.1.2", - "tslib": "^2.0.3" - } - }, "camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", @@ -10572,17 +10410,6 @@ "integrity": "sha512-KCqHwRnaa1InZBtqXzP98LPg0ajCVujMKjqKDhZEthIpAsJl/YEIa3YvXjGXPVqzZVguccuu7ga9KOE1J9rKPQ==", "dev": true }, - "capital-case": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/capital-case/-/capital-case-1.0.4.tgz", - "integrity": "sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A==", - "dev": true, - "requires": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case-first": "^2.0.2" - } - }, "chai": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz", @@ -10609,24 +10436,10 @@ } }, "change-case": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/change-case/-/change-case-4.1.2.tgz", - "integrity": "sha512-bSxY2ws9OtviILG1EiY5K7NNxkqg/JnRnFxLtKQ96JaviiIxi7djMrSd0ECT9AC+lttClmYwKw53BWpOMblo7A==", - "dev": true, - "requires": { - "camel-case": "^4.1.2", - "capital-case": "^1.0.4", - "constant-case": "^3.0.4", - "dot-case": "^3.0.4", - "header-case": "^2.0.4", - "no-case": "^3.0.4", - "param-case": "^3.0.4", - "pascal-case": "^3.1.2", - "path-case": "^3.0.4", - "sentence-case": "^3.0.4", - "snake-case": "^3.0.4", - "tslib": "^2.0.3" - } + "version": "5.4.4", + "resolved": "https://registry.npmjs.org/change-case/-/change-case-5.4.4.tgz", + "integrity": "sha512-HRQyTk2/YPEkt9TnUPbOpr64Uw3KOicFWPVBb+xiHvd6eBx/qPr9xqfBFDT8P2vWsvvz4jbEkfDe71W3VyNu2w==", + "dev": true }, "character-entities": { "version": "2.0.2", @@ -10776,17 +10589,6 @@ "well-known-symbols": "^2.0.0" } }, - "constant-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/constant-case/-/constant-case-3.0.4.tgz", - "integrity": "sha512-I2hSBi7Vvs7BEuJDr5dDHfzb/Ruj3FyvFyh7KLilAjNQw3Be+xgqUBA2W6scVEcL0hL1dwPRtIqEPVUCKkSsyQ==", - "dev": true, - "requires": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case": "^2.0.2" - } - }, "conventional-changelog": { "version": "3.1.25", "resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-3.1.25.tgz", @@ -11213,16 +11015,6 @@ "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", "dev": true }, - "dot-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", - "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", - "dev": true, - "requires": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "dot-prop": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", @@ -12212,16 +12004,6 @@ "has-symbols": "^1.0.2" } }, - "header-case": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/header-case/-/header-case-2.0.4.tgz", - "integrity": "sha512-H/vuk5TEEVZwrR0lp2zed9OCo1uAILMlx0JEMgC26rzyJJ3N1v6XkwHHXJQdR2doSjcGPM6OKPYoJgf0plJ11Q==", - "dev": true, - "requires": { - "capital-case": "^1.0.4", - "tslib": "^2.0.3" - } - }, "headers-polyfill": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/headers-polyfill/-/headers-polyfill-3.1.2.tgz", @@ -12282,9 +12064,9 @@ "dev": true }, "imgix-url-builder": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/imgix-url-builder/-/imgix-url-builder-0.0.3.tgz", - "integrity": "sha512-8Oc2Cn4+jF06sEfJcVPlWYfD2F6RjrwIMbk1xEzux8unoB5LsvFc/GL1BQ47HPaeE12ReX2nMUcjUslGYWLxHA==", + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/imgix-url-builder/-/imgix-url-builder-0.0.5.tgz", + "integrity": "sha512-dCx3UlXghtsjySoqVCcHQHRikqDummwQEfKlxBUK/wrMzd+1ox/XX+zhqVuXKMVuZvCc84pVLEJyntQB0OOi/w==", "dev": true }, "import-fresh": { @@ -12917,15 +12699,6 @@ "get-func-name": "^2.0.0" } }, - "lower-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", - "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", - "dev": true, - "requires": { - "tslib": "^2.0.3" - } - }, "lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -13619,16 +13392,6 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, - "no-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", - "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", - "dev": true, - "requires": { - "lower-case": "^2.0.2", - "tslib": "^2.0.3" - } - }, "node-domexception": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", @@ -13838,16 +13601,6 @@ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, - "param-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", - "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==", - "dev": true, - "requires": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -13867,26 +13620,6 @@ "json-parse-better-errors": "^1.0.1" } }, - "pascal-case": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", - "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", - "dev": true, - "requires": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "path-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/path-case/-/path-case-3.0.4.tgz", - "integrity": "sha512-qO4qCFjXqVTrcbPt/hQfhTQ+VhFsqNKOPtytgNKkKxSoEp3XPUQ8ObFuePylOIok5gjn69ry8XiULxCwot3Wfg==", - "dev": true, - "requires": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -14463,17 +14196,6 @@ } } }, - "sentence-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/sentence-case/-/sentence-case-3.0.4.tgz", - "integrity": "sha512-8LS0JInaQMCRoQ7YUytAo/xUu5W2XnQxV2HI/6uM6U7CITS1RqPElr30V6uIqyMKM9lJGRVFy5/4CuzcixNYSg==", - "dev": true, - "requires": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case-first": "^2.0.2" - } - }, "set-cookie-parser": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.6.0.tgz", @@ -14538,16 +14260,6 @@ "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", "dev": true }, - "snake-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz", - "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==", - "dev": true, - "requires": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -15055,24 +14767,6 @@ "picocolors": "^1.0.0" } }, - "upper-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-2.0.2.tgz", - "integrity": "sha512-KgdgDGJt2TpuwBUIjgG6lzw2GWFRCW9Qkfkiv0DxqHHLYJHmtmdUIKcZd8rHgFSjopVTlw6ggzCm1b8MFQwikg==", - "dev": true, - "requires": { - "tslib": "^2.0.3" - } - }, - "upper-case-first": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/upper-case-first/-/upper-case-first-2.0.2.tgz", - "integrity": "sha512-514ppYHBaKwfJRK/pNC6c/OxfGa0obSnAl106u97Ed0I625Nin96KAjttZF6ZL3e1XLtphxnqrOi9iWgm+u+bg==", - "dev": true, - "requires": { - "tslib": "^2.0.3" - } - }, "uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", diff --git a/package.json b/package.json index 45f1371..5bd0116 100644 --- a/package.json +++ b/package.json @@ -69,8 +69,8 @@ "@prismicio/richtext": "^2.1.5" }, "devDependencies": { - "@prismicio/client": "^7.1.0", - "@prismicio/mock": "^0.3.1", + "@prismicio/client": "7.9.0-alpha.2", + "@prismicio/mock": "0.3.8-alpha.0", "@size-limit/preset-small-lib": "^8.2.4", "@testing-library/react": "^14.0.0", "@types/node-fetch": "^3.0.3", @@ -111,5 +111,9 @@ }, "publishConfig": { "access": "public" + }, + "overrides": { + "@prismicio/client": "7.9.0-alpha.2", + "@prismicio/mock": "0.3.8-alpha.0" } } diff --git a/src/react-server/PrismicLink.tsx b/src/react-server/PrismicLink.tsx index a6bebf2..f9c5823 100644 --- a/src/react-server/PrismicLink.tsx +++ b/src/react-server/PrismicLink.tsx @@ -45,7 +45,10 @@ export interface LinkProps { export type PrismicLinkProps< InternalComponentProps = React.ComponentProps, ExternalComponentProps = React.ComponentProps, -> = Omit & { +> = Omit< + InternalComponentProps & ExternalComponentProps, + "rel" | "href" | "children" +> & { /** * The `rel` attribute for the link. By default, `"noreferrer"` is provided if * the link's URL is external. This prop can be provided a function to use the @@ -75,6 +78,13 @@ export type PrismicLinkProps< * The component rendered for external URLs. Defaults to ``. */ externalComponent?: React.ComponentType; + + /** + * The text to render for the link. If no children is provided and the link + * field contain a 'text' property filled, the 'text' property will be used as + * children. + */ + children?: React.ReactNode; } & ( | { document: PrismicDocument | null | undefined; @@ -103,6 +113,7 @@ export const PrismicLink = React.forwardRef(function PrismicLink< linkResolver, internalComponent, externalComponent, + children, ...restProps }: PrismicLinkProps, ref: React.ForwardedRef, @@ -161,6 +172,11 @@ export const PrismicLink = React.forwardRef(function PrismicLink< const href = ("href" in restProps ? restProps.href : computedHref) || ""; + let text: string | undefined; + if (field && "text" in field) { + text = field.text; + } + const InternalComponent = (internalComponent || defaultComponent) as React.ComponentType; const ExternalComponent = (externalComponent || @@ -169,7 +185,9 @@ export const PrismicLink = React.forwardRef(function PrismicLink< href && isInternalURL(href) ? InternalComponent : ExternalComponent; return ( - + + {children || text} + ); }) as < InternalComponentProps = React.ComponentProps, diff --git a/test/PrismicLink.test.tsx b/test/PrismicLink.test.tsx index 5190f68..7ab05dd 100644 --- a/test/PrismicLink.test.tsx +++ b/test/PrismicLink.test.tsx @@ -79,3 +79,50 @@ it("if URL is external and externalComponent is given to the provider and the co expect(actual).toStrictEqual(expected); }); + +it("if link text is provided without children, render link with the text", async (ctx) => { + const field = ctx.mock.value.link({ + type: "Web", + model: { + type: "Link", + config: { + text: { + type: "Text", + }, + }, + }, + }); + const actual = renderJSON(); + const expected = renderJSON( + + {field.text} + , + ); + + expect(actual).toStrictEqual(expected); +}); + +it("if link text is provided with children, render link with given children", async (ctx) => { + const field = ctx.mock.value.link({ + type: "Web", + model: { + type: "Link", + config: { + text: { + type: "Text", + }, + }, + }, + }); + const children = ctx.mock.value.keyText(); + const actual = renderJSON( + {children}, + ); + const expected = renderJSON( + + {children} + , + ); + + expect(actual).toStrictEqual(expected); +}); diff --git a/test/react-server/PrismicRichText.test.tsx b/test/react-server/PrismicRichText.test.tsx index e5a17d0..b2c392b 100644 --- a/test/react-server/PrismicRichText.test.tsx +++ b/test/react-server/PrismicRichText.test.tsx @@ -289,6 +289,13 @@ it("returns if type is image", async () => { const field: prismic.RichTextField = [ { + id: "", + edit: { + background: "transparent", + x: 0, + y: 0, + zoom: 1, + }, type: prismic.RichTextNodeType.image, url, alt, @@ -316,6 +323,13 @@ it("returns with undefined copyright if not provided", async () => { const field: prismic.RichTextField = [ { + id: "", + edit: { + background: "transparent", + x: 0, + y: 0, + zoom: 1, + }, type: prismic.RichTextNodeType.image, url, alt, @@ -346,6 +360,13 @@ it("returns wrapped in ", async (ctx) => { const field: prismic.RichTextField = [ { + id: "", + edit: { + background: "transparent", + x: 0, + y: 0, + zoom: 1, + }, type: prismic.RichTextNodeType.image, url, alt, From 35871a4fd6dae5a60db01b367cac4129e4a9cda3 Mon Sep 17 00:00:00 2001 From: Xavier Rutayisire Date: Thu, 29 Aug 2024 10:06:11 +0200 Subject: [PATCH 02/11] review fixes --- src/react-server/PrismicLink.tsx | 12 ++++-------- test/PrismicLink.test.tsx | 30 ++++++------------------------ 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/src/react-server/PrismicLink.tsx b/src/react-server/PrismicLink.tsx index f9c5823..d67332b 100644 --- a/src/react-server/PrismicLink.tsx +++ b/src/react-server/PrismicLink.tsx @@ -5,6 +5,7 @@ import { PrismicDocument, asLinkAttrs, AsLinkAttrsConfig, + isFilled, } from "@prismicio/client"; import { devMsg } from "../lib/devMsg"; @@ -80,9 +81,8 @@ export type PrismicLinkProps< externalComponent?: React.ComponentType; /** - * The text to render for the link. If no children is provided and the link - * field contain a 'text' property filled, the 'text' property will be used as - * children. + * The children to render for the link. If no children are provided, the + * link's `text` property will be used. */ children?: React.ReactNode; } & ( @@ -171,11 +171,7 @@ export const PrismicLink = React.forwardRef(function PrismicLink< } const href = ("href" in restProps ? restProps.href : computedHref) || ""; - - let text: string | undefined; - if (field && "text" in field) { - text = field.text; - } + const text = isFilled.link(field) ? field.text : undefined; const InternalComponent = (internalComponent || defaultComponent) as React.ComponentType; diff --git a/test/PrismicLink.test.tsx b/test/PrismicLink.test.tsx index 7ab05dd..2002f8c 100644 --- a/test/PrismicLink.test.tsx +++ b/test/PrismicLink.test.tsx @@ -80,18 +80,9 @@ it("if URL is external and externalComponent is given to the provider and the co expect(actual).toStrictEqual(expected); }); -it("if link text is provided without children, render link with the text", async (ctx) => { - const field = ctx.mock.value.link({ - type: "Web", - model: { - type: "Link", - config: { - text: { - type: "Text", - }, - }, - }, - }); +it("renders the link's text if no children are provided", async (ctx) => { + const model = ctx.mock.model.link({ text: true }); + const field = ctx.mock.value.link({ type: "Web", model }); const actual = renderJSON(); const expected = renderJSON( @@ -102,18 +93,9 @@ it("if link text is provided without children, render link with the text", async expect(actual).toStrictEqual(expected); }); -it("if link text is provided with children, render link with given children", async (ctx) => { - const field = ctx.mock.value.link({ - type: "Web", - model: { - type: "Link", - config: { - text: { - type: "Text", - }, - }, - }, - }); +it("renders the given children, overriding the link's text", async (ctx) => { + const model = ctx.mock.model.link({ text: true }); + const field = ctx.mock.value.link({ type: "Web", model }); const children = ctx.mock.value.keyText(); const actual = renderJSON( {children}, From 5b945b198973248b2a9ec755a46225fe056bd574 Mon Sep 17 00:00:00 2001 From: Xavier Rutayisire Date: Fri, 30 Aug 2024 14:00:05 +0200 Subject: [PATCH 03/11] review fixes --- src/react-server/PrismicLink.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/react-server/PrismicLink.tsx b/src/react-server/PrismicLink.tsx index d67332b..203519a 100644 --- a/src/react-server/PrismicLink.tsx +++ b/src/react-server/PrismicLink.tsx @@ -182,7 +182,7 @@ export const PrismicLink = React.forwardRef(function PrismicLink< return ( - {children || text} + {"children" in restProps ? children : text} ); }) as < From d73bfef28133647f9a63e9a2d30913e02ecfd31a Mon Sep 17 00:00:00 2001 From: Xavier Rutayisire Date: Fri, 30 Aug 2024 14:05:44 +0200 Subject: [PATCH 04/11] review fixes --- src/react-server/PrismicLink.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/react-server/PrismicLink.tsx b/src/react-server/PrismicLink.tsx index 203519a..86107bc 100644 --- a/src/react-server/PrismicLink.tsx +++ b/src/react-server/PrismicLink.tsx @@ -107,7 +107,10 @@ export const PrismicLink = React.forwardRef(function PrismicLink< InternalComponentProps = React.ComponentProps, ExternalComponentProps = React.ComponentProps, >( - { + props: PrismicLinkProps, + ref: React.ForwardedRef, +): JSX.Element { + const { field, document: doc, linkResolver, @@ -115,9 +118,8 @@ export const PrismicLink = React.forwardRef(function PrismicLink< externalComponent, children, ...restProps - }: PrismicLinkProps, - ref: React.ForwardedRef, -): JSX.Element { + } = props; + if ( typeof process !== "undefined" && process.env.NODE_ENV === "development" @@ -182,7 +184,7 @@ export const PrismicLink = React.forwardRef(function PrismicLink< return ( - {"children" in restProps ? children : text} + {"children" in props ? children : text} ); }) as < From 3fd7cc4c134ad9a73e9b457eed10bef6a7ec87bc Mon Sep 17 00:00:00 2001 From: Xavier Rutayisire Date: Sun, 8 Sep 2024 00:10:22 +0200 Subject: [PATCH 05/11] support when empty link has text --- src/react-server/PrismicLink.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/react-server/PrismicLink.tsx b/src/react-server/PrismicLink.tsx index 86107bc..af3f94f 100644 --- a/src/react-server/PrismicLink.tsx +++ b/src/react-server/PrismicLink.tsx @@ -136,7 +136,9 @@ export const PrismicLink = React.forwardRef(function PrismicLink< )}`, ); } else if ( - Object.keys(field).length > 1 && + ("text" in field + ? Object.keys(field).length > 2 + : Object.keys(field).length > 1) && !("url" in field || "uid" in field || "id" in field) ) { console.warn( @@ -173,7 +175,6 @@ export const PrismicLink = React.forwardRef(function PrismicLink< } const href = ("href" in restProps ? restProps.href : computedHref) || ""; - const text = isFilled.link(field) ? field.text : undefined; const InternalComponent = (internalComponent || defaultComponent) as React.ComponentType; @@ -184,7 +185,7 @@ export const PrismicLink = React.forwardRef(function PrismicLink< return ( - {"children" in props ? children : text} + {"children" in props ? children : field?.text} ); }) as < From b8d6494b311a3a3a369102b48022b43a92d7c224 Mon Sep 17 00:00:00 2001 From: Xavier Rutayisire Date: Tue, 10 Sep 2024 23:34:14 +0200 Subject: [PATCH 06/11] update prismic-client & prismic-mock --- package-lock.json | 28 ++++++++++++++-------------- package.json | 8 ++++---- src/react-server/PrismicLink.tsx | 1 - test/PrismicLink.test.tsx | 4 ++-- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7117e15..651644a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,8 +12,8 @@ "@prismicio/richtext": "^2.1.5" }, "devDependencies": { - "@prismicio/client": "7.9.0-alpha.2", - "@prismicio/mock": "0.3.8-alpha.0", + "@prismicio/client": "7.9.0-alpha.3", + "@prismicio/mock": "0.3.8-alpha.2", "@size-limit/preset-small-lib": "^8.2.4", "@testing-library/react": "^14.0.0", "@types/node-fetch": "^3.0.3", @@ -1156,9 +1156,9 @@ "dev": true }, "node_modules/@prismicio/client": { - "version": "7.9.0-alpha.2", - "resolved": "https://registry.npmjs.org/@prismicio/client/-/client-7.9.0-alpha.2.tgz", - "integrity": "sha512-Y4Ti7XoJ57Rk2AkhI0UBxg3f2+wGr4ZwGfr82bFbmY9CCAUXQ+aN8cl3nUSCUafhRyJTcqWSty52D8RKvseY4g==", + "version": "7.9.0-alpha.3", + "resolved": "https://registry.npmjs.org/@prismicio/client/-/client-7.9.0-alpha.3.tgz", + "integrity": "sha512-8u+ot1xTt/wH8BSlnYJ20+fuZRo4TIf4PnkNFMLkgYmNbUTNnsNFsPr0GJC/G9nTZFnn5jV0oTPz48C/ITVnnA==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -1169,9 +1169,9 @@ } }, "node_modules/@prismicio/mock": { - "version": "0.3.8-alpha.0", - "resolved": "https://registry.npmjs.org/@prismicio/mock/-/mock-0.3.8-alpha.0.tgz", - "integrity": "sha512-w8yGiL6cmapktjeb47IS4zdqFArfo+cC81ahdoDBShOjREqQjzTHECihMudcnePav5Ok11IUHXB0F5Il3aaRjA==", + "version": "0.3.8-alpha.2", + "resolved": "https://registry.npmjs.org/@prismicio/mock/-/mock-0.3.8-alpha.2.tgz", + "integrity": "sha512-LtLeIp88Y1vvQzyWCcK0k0aYdoexh7Yep31WeiUmZXnZ8p91sliw9HXZDEHqnKX2SjZx6sSv+P7oBVcq6IsH+g==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -9601,18 +9601,18 @@ "dev": true }, "@prismicio/client": { - "version": "7.9.0-alpha.2", - "resolved": "https://registry.npmjs.org/@prismicio/client/-/client-7.9.0-alpha.2.tgz", - "integrity": "sha512-Y4Ti7XoJ57Rk2AkhI0UBxg3f2+wGr4ZwGfr82bFbmY9CCAUXQ+aN8cl3nUSCUafhRyJTcqWSty52D8RKvseY4g==", + "version": "7.9.0-alpha.3", + "resolved": "https://registry.npmjs.org/@prismicio/client/-/client-7.9.0-alpha.3.tgz", + "integrity": "sha512-8u+ot1xTt/wH8BSlnYJ20+fuZRo4TIf4PnkNFMLkgYmNbUTNnsNFsPr0GJC/G9nTZFnn5jV0oTPz48C/ITVnnA==", "dev": true, "requires": { "imgix-url-builder": "^0.0.5" } }, "@prismicio/mock": { - "version": "0.3.8-alpha.0", - "resolved": "https://registry.npmjs.org/@prismicio/mock/-/mock-0.3.8-alpha.0.tgz", - "integrity": "sha512-w8yGiL6cmapktjeb47IS4zdqFArfo+cC81ahdoDBShOjREqQjzTHECihMudcnePav5Ok11IUHXB0F5Il3aaRjA==", + "version": "0.3.8-alpha.2", + "resolved": "https://registry.npmjs.org/@prismicio/mock/-/mock-0.3.8-alpha.2.tgz", + "integrity": "sha512-LtLeIp88Y1vvQzyWCcK0k0aYdoexh7Yep31WeiUmZXnZ8p91sliw9HXZDEHqnKX2SjZx6sSv+P7oBVcq6IsH+g==", "dev": true, "requires": { "change-case": "^5.4.4" diff --git a/package.json b/package.json index 5bd0116..56d1257 100644 --- a/package.json +++ b/package.json @@ -69,8 +69,8 @@ "@prismicio/richtext": "^2.1.5" }, "devDependencies": { - "@prismicio/client": "7.9.0-alpha.2", - "@prismicio/mock": "0.3.8-alpha.0", + "@prismicio/client": "7.9.0-alpha.3", + "@prismicio/mock": "0.3.8-alpha.2", "@size-limit/preset-small-lib": "^8.2.4", "@testing-library/react": "^14.0.0", "@types/node-fetch": "^3.0.3", @@ -113,7 +113,7 @@ "access": "public" }, "overrides": { - "@prismicio/client": "7.9.0-alpha.2", - "@prismicio/mock": "0.3.8-alpha.0" + "@prismicio/client": "7.9.0-alpha.3", + "@prismicio/mock": "0.3.8-alpha.2" } } diff --git a/src/react-server/PrismicLink.tsx b/src/react-server/PrismicLink.tsx index af3f94f..f00a276 100644 --- a/src/react-server/PrismicLink.tsx +++ b/src/react-server/PrismicLink.tsx @@ -5,7 +5,6 @@ import { PrismicDocument, asLinkAttrs, AsLinkAttrsConfig, - isFilled, } from "@prismicio/client"; import { devMsg } from "../lib/devMsg"; diff --git a/test/PrismicLink.test.tsx b/test/PrismicLink.test.tsx index 2002f8c..5667b51 100644 --- a/test/PrismicLink.test.tsx +++ b/test/PrismicLink.test.tsx @@ -81,7 +81,7 @@ it("if URL is external and externalComponent is given to the provider and the co }); it("renders the link's text if no children are provided", async (ctx) => { - const model = ctx.mock.model.link({ text: true }); + const model = ctx.mock.model.link({ allowText: true }); const field = ctx.mock.value.link({ type: "Web", model }); const actual = renderJSON(); const expected = renderJSON( @@ -94,7 +94,7 @@ it("renders the link's text if no children are provided", async (ctx) => { }); it("renders the given children, overriding the link's text", async (ctx) => { - const model = ctx.mock.model.link({ text: true }); + const model = ctx.mock.model.link({ allowText: true }); const field = ctx.mock.value.link({ type: "Web", model }); const children = ctx.mock.value.keyText(); const actual = renderJSON( From 9d8f76cdeb6a9000e414033e88047c155e6ce656 Mon Sep 17 00:00:00 2001 From: Xavier Rutayisire Date: Tue, 10 Sep 2024 23:35:11 +0200 Subject: [PATCH 07/11] chore(release): 2.9.0-alpha.0 --- CHANGELOG.md | 13 +++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3903f13..64d28ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [2.9.0-alpha.0](https://github.com/prismicio/prismic-react/compare/v2.7.4...v2.9.0-alpha.0) (2024-09-10) + + +### Features + +* support link text ([aeeedcd](https://github.com/prismicio/prismic-react/commit/aeeedcd70058a73f1a00da0d12f2a555ab5d5cf0)) +* support React 19 ([c06d5c1](https://github.com/prismicio/prismic-react/commit/c06d5c13a9313efc5dda0c98f714803789b48bf8)) + + +### Chore + +* **release:** 2.8.0 ([2f15c25](https://github.com/prismicio/prismic-react/commit/2f15c2592d41672e2b76921b3ebeebfb1c4617f0)) + ## [2.8.0](https://github.com/prismicio/prismic-react/compare/v2.7.4...v2.8.0) (2024-05-30) diff --git a/package-lock.json b/package-lock.json index 651644a..cb61206 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@prismicio/react", - "version": "2.8.0", + "version": "2.9.0-alpha.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@prismicio/react", - "version": "2.8.0", + "version": "2.9.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@prismicio/richtext": "^2.1.5" diff --git a/package.json b/package.json index 56d1257..c4da955 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@prismicio/react", - "version": "2.8.0", + "version": "2.9.0-alpha.0", "description": "React components and hooks to fetch and present Prismic content", "keywords": [ "typescript", From a440cffcdcfd72311c85cf4377e953520f86f7a3 Mon Sep 17 00:00:00 2001 From: Xavier Rutayisire Date: Tue, 10 Sep 2024 23:53:00 +0200 Subject: [PATCH 08/11] update test --- test/PrismicLink.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/PrismicLink.test.tsx b/test/PrismicLink.test.tsx index 5667b51..69b0c4a 100644 --- a/test/PrismicLink.test.tsx +++ b/test/PrismicLink.test.tsx @@ -82,7 +82,7 @@ it("if URL is external and externalComponent is given to the provider and the co it("renders the link's text if no children are provided", async (ctx) => { const model = ctx.mock.model.link({ allowText: true }); - const field = ctx.mock.value.link({ type: "Web", model }); + const field = ctx.mock.value.link({ type: "Web", model, withText: true }); const actual = renderJSON(); const expected = renderJSON( @@ -95,7 +95,7 @@ it("renders the link's text if no children are provided", async (ctx) => { it("renders the given children, overriding the link's text", async (ctx) => { const model = ctx.mock.model.link({ allowText: true }); - const field = ctx.mock.value.link({ type: "Web", model }); + const field = ctx.mock.value.link({ type: "Web", model, withText: true }); const children = ctx.mock.value.keyText(); const actual = renderJSON( {children}, From 4ddad424a2ae9752e13d848a644c31f0ac3d22f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marti=CC=81n?= Date: Fri, 27 Sep 2024 12:39:49 +0200 Subject: [PATCH 09/11] Upgrade prismic devs --- examples/with-typescript/package.json | 2 +- package-lock.json | 14 +++++++------- package.json | 8 ++------ src/useStatefulPrismicClientMethod.ts | 8 ++------ 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/examples/with-typescript/package.json b/examples/with-typescript/package.json index cc75ce7..7ab8f56 100644 --- a/examples/with-typescript/package.json +++ b/examples/with-typescript/package.json @@ -4,6 +4,6 @@ "@prismicio/react": "../../src" }, "devDependencies": { - "@prismicio/client": "7.9.0-alpha.2" + "@prismicio/client": "^7.11.0" } } diff --git a/package-lock.json b/package-lock.json index cb61206..ffc11da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@prismicio/richtext": "^2.1.5" }, "devDependencies": { - "@prismicio/client": "7.9.0-alpha.3", + "@prismicio/client": "^7.11.0", "@prismicio/mock": "0.3.8-alpha.2", "@size-limit/preset-small-lib": "^8.2.4", "@testing-library/react": "^14.0.0", @@ -1156,9 +1156,9 @@ "dev": true }, "node_modules/@prismicio/client": { - "version": "7.9.0-alpha.3", - "resolved": "https://registry.npmjs.org/@prismicio/client/-/client-7.9.0-alpha.3.tgz", - "integrity": "sha512-8u+ot1xTt/wH8BSlnYJ20+fuZRo4TIf4PnkNFMLkgYmNbUTNnsNFsPr0GJC/G9nTZFnn5jV0oTPz48C/ITVnnA==", + "version": "7.11.0", + "resolved": "https://registry.npmjs.org/@prismicio/client/-/client-7.11.0.tgz", + "integrity": "sha512-b5FtER97eFHH435hP4sRchtPYvrwa8v2Ye5IH3MhMp/6aH6kRSrr9fDA4+wkqF/ZK9aiJwJRkjdddgkwDFu9Vg==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -9601,9 +9601,9 @@ "dev": true }, "@prismicio/client": { - "version": "7.9.0-alpha.3", - "resolved": "https://registry.npmjs.org/@prismicio/client/-/client-7.9.0-alpha.3.tgz", - "integrity": "sha512-8u+ot1xTt/wH8BSlnYJ20+fuZRo4TIf4PnkNFMLkgYmNbUTNnsNFsPr0GJC/G9nTZFnn5jV0oTPz48C/ITVnnA==", + "version": "7.11.0", + "resolved": "https://registry.npmjs.org/@prismicio/client/-/client-7.11.0.tgz", + "integrity": "sha512-b5FtER97eFHH435hP4sRchtPYvrwa8v2Ye5IH3MhMp/6aH6kRSrr9fDA4+wkqF/ZK9aiJwJRkjdddgkwDFu9Vg==", "dev": true, "requires": { "imgix-url-builder": "^0.0.5" diff --git a/package.json b/package.json index c4da955..e30f9cb 100644 --- a/package.json +++ b/package.json @@ -69,8 +69,8 @@ "@prismicio/richtext": "^2.1.5" }, "devDependencies": { - "@prismicio/client": "7.9.0-alpha.3", - "@prismicio/mock": "0.3.8-alpha.2", + "@prismicio/client": "^7.11.0", + "@prismicio/mock": "0.4.0", "@size-limit/preset-small-lib": "^8.2.4", "@testing-library/react": "^14.0.0", "@types/node-fetch": "^3.0.3", @@ -111,9 +111,5 @@ }, "publishConfig": { "access": "public" - }, - "overrides": { - "@prismicio/client": "7.9.0-alpha.3", - "@prismicio/mock": "0.3.8-alpha.2" } } diff --git a/src/useStatefulPrismicClientMethod.ts b/src/useStatefulPrismicClientMethod.ts index faa29b0..f547dee 100644 --- a/src/useStatefulPrismicClientMethod.ts +++ b/src/useStatefulPrismicClientMethod.ts @@ -148,13 +148,9 @@ export const useStatefulPrismicClientMethod = < dispatch(["start"]); } + // @ts-expect-error - Merging method arg types is too complex client[methodName] - .call( - client, - // @ts-expect-error - Merging method arg types is too complex - ...argsWithoutParams, - params, - ) + .call(client, ...argsWithoutParams, params) .then((result) => { if (!didCancel) { dispatch(["succeed", result as TData]); From ae2c524ba8845e0b4599b05bc427cf9a3b61c6b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marti=CC=81n?= Date: Fri, 27 Sep 2024 12:40:20 +0200 Subject: [PATCH 10/11] chore(release): 2.9.0 --- CHANGELOG.md | 2 ++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64d28ca..8f4f66c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [2.9.0](https://github.com/prismicio/prismic-react/compare/v2.9.0-alpha.0...v2.9.0) (2024-09-27) + ## [2.9.0-alpha.0](https://github.com/prismicio/prismic-react/compare/v2.7.4...v2.9.0-alpha.0) (2024-09-10) diff --git a/package-lock.json b/package-lock.json index ffc11da..bed7f82 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@prismicio/react", - "version": "2.9.0-alpha.0", + "version": "2.9.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@prismicio/react", - "version": "2.9.0-alpha.0", + "version": "2.9.0", "license": "Apache-2.0", "dependencies": { "@prismicio/richtext": "^2.1.5" diff --git a/package.json b/package.json index e30f9cb..102c500 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@prismicio/react", - "version": "2.9.0-alpha.0", + "version": "2.9.0", "description": "React components and hooks to fetch and present Prismic content", "keywords": [ "typescript", From e68a6e301b84e56dcd57700039a3cc8836edbe3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marti=CC=81n?= Date: Fri, 27 Sep 2024 12:43:11 +0200 Subject: [PATCH 11/11] Fix ci --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a35b0b..6c725d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - node: [16] + node: [18] steps: - uses: actions/setup-node@v2 @@ -45,11 +45,11 @@ jobs: run: npm run build - name: Coverage - if: matrix.os == 'ubuntu-latest' && matrix.node == 16 + if: matrix.os == 'ubuntu-latest' && matrix.node == 18 uses: codecov/codecov-action@v1 - name: Size - if: github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' && matrix.node == 16 + if: github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' && matrix.node == 18 uses: andresz1/size-limit-action@v1 with: github_token: ${{ secrets.GITHUB_TOKEN }}