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 }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 3903f13..8f4f66c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,21 @@ 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) + + +### 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/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..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.5.0" + "@prismicio/client": "^7.11.0" } } diff --git a/package-lock.json b/package-lock.json index e3e6699..bed7f82 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,19 @@ { "name": "@prismicio/react", - "version": "2.8.0", + "version": "2.9.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@prismicio/react", - "version": "2.8.0", + "version": "2.9.0", "license": "Apache-2.0", "dependencies": { "@prismicio/richtext": "^2.1.5" }, "devDependencies": { - "@prismicio/client": "^7.1.0", - "@prismicio/mock": "^0.3.1", + "@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", "@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.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": { - "@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.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": { - "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.11.0", + "resolved": "https://registry.npmjs.org/@prismicio/client/-/client-7.11.0.tgz", + "integrity": "sha512-b5FtER97eFHH435hP4sRchtPYvrwa8v2Ye5IH3MhMp/6aH6kRSrr9fDA4+wkqF/ZK9aiJwJRkjdddgkwDFu9Vg==", "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.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": "^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..102c500 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@prismicio/react", - "version": "2.8.0", + "version": "2.9.0", "description": "React components and hooks to fetch and present Prismic content", "keywords": [ "typescript", @@ -69,8 +69,8 @@ "@prismicio/richtext": "^2.1.5" }, "devDependencies": { - "@prismicio/client": "^7.1.0", - "@prismicio/mock": "^0.3.1", + "@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", diff --git a/src/react-server/PrismicLink.tsx b/src/react-server/PrismicLink.tsx index a6bebf2..f00a276 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,12 @@ export type PrismicLinkProps< * The component rendered for external URLs. Defaults to ``. */ externalComponent?: React.ComponentType; + + /** + * The children to render for the link. If no children are provided, the + * link's `text` property will be used. + */ + children?: React.ReactNode; } & ( | { document: PrismicDocument | null | undefined; @@ -97,16 +106,19 @@ 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, internalComponent, externalComponent, + children, ...restProps - }: PrismicLinkProps, - ref: React.ForwardedRef, -): JSX.Element { + } = props; + if ( typeof process !== "undefined" && process.env.NODE_ENV === "development" @@ -123,7 +135,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( @@ -169,7 +183,9 @@ export const PrismicLink = React.forwardRef(function PrismicLink< href && isInternalURL(href) ? InternalComponent : ExternalComponent; return ( - + + {"children" in props ? children : field?.text} + ); }) as < InternalComponentProps = React.ComponentProps, 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]); diff --git a/test/PrismicLink.test.tsx b/test/PrismicLink.test.tsx index 5190f68..69b0c4a 100644 --- a/test/PrismicLink.test.tsx +++ b/test/PrismicLink.test.tsx @@ -79,3 +79,32 @@ it("if URL is external and externalComponent is given to the provider and the co expect(actual).toStrictEqual(expected); }); + +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, withText: true }); + const actual = renderJSON(); + const expected = renderJSON( + + {field.text} + , + ); + + expect(actual).toStrictEqual(expected); +}); + +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, withText: true }); + 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,