diff --git a/.changeset/afraid-scissors-work.md b/.changeset/afraid-scissors-work.md new file mode 100644 index 00000000000..a38aecb4060 --- /dev/null +++ b/.changeset/afraid-scissors-work.md @@ -0,0 +1,5 @@ +--- +'@shopify/polaris': major +--- + +Change breadcrumbs from an array to a single backAction since only one is supported. diff --git a/.changeset/few-forks-change.md b/.changeset/few-forks-change.md new file mode 100644 index 00000000000..ed4db1d95aa --- /dev/null +++ b/.changeset/few-forks-change.md @@ -0,0 +1,5 @@ +--- +'@shopify/polaris': major +--- + +No longer transpile optional chaining, nullish coalescing or numeric separators, as our target browser environments all have native support for these syntaxes. This removes support for apps using webpack4, which unable to parse these syntaxes. diff --git a/.changeset/light-mails-type.md b/.changeset/light-mails-type.md new file mode 100644 index 00000000000..129a997ab95 --- /dev/null +++ b/.changeset/light-mails-type.md @@ -0,0 +1,6 @@ +--- +'@shopify/polaris': minor +'polaris.shopify.com': minor +--- + +Replaced `Stack` with `AlphaStack` diff --git a/.changeset/nasty-suns-hang.md b/.changeset/nasty-suns-hang.md new file mode 100644 index 00000000000..1e6a0d0f28d --- /dev/null +++ b/.changeset/nasty-suns-hang.md @@ -0,0 +1,5 @@ +--- +'polaris.shopify.com': patch +--- + +Removed beta status from `Text` diff --git a/.changeset/real-lemons-sniff.md b/.changeset/real-lemons-sniff.md new file mode 100644 index 00000000000..d4c1690f2a0 --- /dev/null +++ b/.changeset/real-lemons-sniff.md @@ -0,0 +1,6 @@ +--- +'@shopify/polaris': major +'polaris.shopify.com': minor +--- + +Removed deprecated `DisplayText`, `Heading`, `Subheading`, `Caption`, `TextStyle`, and `VisuallyHidden` components diff --git a/.changeset/six-jokes-drum.md b/.changeset/six-jokes-drum.md new file mode 100644 index 00000000000..44ceb0da8fb --- /dev/null +++ b/.changeset/six-jokes-drum.md @@ -0,0 +1,6 @@ +--- +'@shopify/polaris': major +'polaris.shopify.com': minor +--- + +Replaced `Card` with `AlphaCard` diff --git a/.changeset/stupid-vans-kick.md b/.changeset/stupid-vans-kick.md new file mode 100644 index 00000000000..d096a5b3b04 --- /dev/null +++ b/.changeset/stupid-vans-kick.md @@ -0,0 +1,5 @@ +--- +'@shopify/polaris': major +--- + +Removed deprecated preventMeasuringOnChildUpdate prop on Collapsible diff --git a/.eslintrc.js b/.eslintrc.js index 3bd03661495..209ca364852 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -55,6 +55,11 @@ module.exports = { 'react/button-has-type': 'off', 'react/no-array-index-key': 'off', 'react/no-unsafe': ['error', {checkAliases: true}], + + // These can be removed when eslint-plugin-react is updated + 'react/jsx-uses-react': 'off', + 'react/react-in-jsx-scope': 'off', + '@shopify/jsx-no-complex-expressions': 'off', '@shopify/jsx-prefer-fragment-wrappers': 'off', '@shopify/no-ancestor-directory-import': 'error', @@ -129,12 +134,6 @@ module.exports = { 'import/extensions': 'off', 'import/no-default-export': 'off', 'import/no-anonymous-default-export': 'off', - // We could omit this if we set `engines` fields properly - // As we don't set them then eslint thinks we're using node 8 - 'node/no-unsupported-features/node-builtins': [ - 'error', - {version: '>=16.0.0'}, - ], }, }, { @@ -171,7 +170,6 @@ module.exports = { files: ['polaris.shopify.com/**/*'], extends: 'plugin:@next/eslint-plugin-next/recommended', rules: { - 'react/react-in-jsx-scope': 'off', '@shopify/jsx-no-hardcoded-content': 'off', 'import/no-default-export': 'off', }, diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 1f564d2fd4e..c180ab5b00f 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -137,7 +137,7 @@ Each contributor is required to [sign a CLA](https://cla.shopify.com/). This pro ### Contribution prerequisites -- You have Node installed at v16.13.0+ and Yarn at v1.22.18+ +- You have Node installed at v18.12.0+ and Yarn at v1.22.18+ ### Best practices diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index cffce71434f..3493dbfeb97 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -21,10 +21,10 @@ jobs: with: fetch-depth: 0 - - name: Setup Node with v16.13.0 + - name: Setup Node with v18.12.0 uses: actions/setup-node@v3 with: - node-version: 16.13.0 + node-version: 18.12.0 - name: Check for Changeset run: npx @changesets/cli status --since="origin/main" diff --git a/.github/workflows/ci-a11y-vrt.yml b/.github/workflows/ci-a11y-vrt.yml index 5e1fbf07268..a89c5d373d1 100644 --- a/.github/workflows/ci-a11y-vrt.yml +++ b/.github/workflows/ci-a11y-vrt.yml @@ -32,10 +32,10 @@ jobs: sudo rm -rf "/usr/local/share/boost" sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - name: Setup Node with v16.13.0 + - name: Setup Node with v18.12.0 uses: actions/setup-node@v3 with: - node-version: 16.13.0 + node-version: 18.12.0 cache: yarn - name: Restore cache @@ -72,10 +72,10 @@ jobs: with: fetch-depth: 0 # Chromatic git history to track changes - - name: Setup Node with v16.13.0 + - name: Setup Node with v18.12.0 uses: actions/setup-node@v3 with: - node-version: 16.13.0 + node-version: 18.12.0 cache: yarn - name: Restore cache diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 509657253fe..6a74d136c14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: ['14.17.0', '16.13.0'] + node-version: ['16.17.0', '18.12.0'] steps: - name: Checkout branch uses: actions/checkout@v3 diff --git a/.gitignore b/.gitignore index 216460d8af7..5b6ebc0a66d 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ Session.vim /polaris.shopify.com/public/sitemap.xml /polaris.shopify.com/public/og-images /polaris.shopify.com/public/playroom +storybook-static diff --git a/.nvmrc b/.nvmrc index ff650592a1e..9dfef472196 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v16.13.0 +v18.12.0 diff --git a/babel.config.js b/babel.config.js index 7ca7b5ca135..63cc19b1bc7 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,15 +1,64 @@ /** * @type {import('@babel/core').TransformOptions} */ -module.exports = { - presets: [['@shopify/babel-preset', {typescript: true, react: true}]], - babelrcRoots: [ - '.', - // Note: The following projects use rootMode: 'upward' to inherit - // and merge with this root level config. - './polaris-migrator', - './polaris-tokens', - './polaris-icons', - './polaris-react', - ], +module.exports = function (api) { + const envName = api.env(); + const development = envName === 'development' || envName === 'test'; + + return { + presets: [ + [ + '@babel/preset-env', + {useBuiltIns: 'entry', corejs: '3.0', bugfixes: true}, + ], + ['@babel/preset-typescript'], + [ + '@babel/preset-react', + { + runtime: 'automatic', + development, + }, + ], + ], + assumptions: { + setPublicClassFields: true, + privateFieldsAsProperties: true, + // nothing accesses `document.all`: + noDocumentAll: true, + // nothing relies on class constructors invoked without `new` throwing: + noClassCalls: true, + // nothing should be relying on tagged template strings being frozen: + mutableTemplateObject: true, + // nothing is relying on Function.prototype.length: + ignoreFunctionLength: true, + // nothing is relying on mutable re-exported bindings: + constantReexports: true, + // don't bother marking Module records non-enumerable: + enumerableModuleMeta: true, + // nothing uses [[Symbol.toPrimitive]]: + // (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive) + ignoreToPrimitiveHint: true, + // nothing relies on spread copying Symbol keys: ({...{ [Symbol()]: 1 }}) + objectRestNoSymbols: true, + // nothing relies on `new (() => {})` throwing: + noNewArrows: true, + // transpile object spread to assignment instead of defineProperty(): + setSpreadProperties: true, + // nothing should be using custom iterator protocol: + skipForOfIteratorClosing: true, + // nothing inherits from a constructor function with explicit return value: + superIsCallableConstructor: true, + // nothing relies on CJS-transpiled namespace imports having all properties prior to module execution completing: + noIncompleteNsImportDetection: true, + }, + babelrcRoots: [ + '.', + // Note: The following projects use rootMode: 'upward' to inherit + // and merge with this root level config. + './polaris-migrator', + './polaris-tokens', + './polaris-icons', + './polaris-react', + ], + }; }; diff --git a/dev.yml b/dev.yml index 9ff7e7c0a44..83940cd41d2 100644 --- a/dev.yml +++ b/dev.yml @@ -2,7 +2,7 @@ name: polaris up: - node: yarn: v1.22.18 - version: v16.13.0 # to be kept in sync with .nvmrc and .github/workflows/ci.yml + version: v18.12.0 # to be kept in sync with .nvmrc and .github/workflows/ci.yml - custom: name: Build monorepo met?: yarn build --output-logs=none diff --git a/documentation/Nodejs support.md b/documentation/Nodejs support.md index 3ad0a11818a..dfe4e9dc591 100644 --- a/documentation/Nodejs support.md +++ b/documentation/Nodejs support.md @@ -16,26 +16,26 @@ The `package.json` engines. This should match the `.github/workflows/ci.yml` and ```json "engines": { - "node": "^14.17.0 || ^16.13.0" + "node": "^16.17.0 || >=18.12.0" }, ``` The GitHub actions `.github/workflows/ci.yml` file. This should match the `package.json` and list all supported versions. ```yml -node-version: ['14.17.0', '16.13.0'] +node-version: ['16.17.0', '18.12.0'] ``` The `dev.yml` file which creates a local development environment. This should match the `.nvmrc` file. ```yml -version: v16.13.0 +version: v18.12.0 ``` The `.nvmrc` file for local development. This should match the `dev.yml` file. ``` -v16.13.0 +v18.12.0 ``` The `shipit.yml` files. This should point towards the GitHub Actions the packages require to pass before publishing. @@ -43,11 +43,13 @@ The `shipit.yml` files. This should point towards the GitHub Actions the package ```yml ci: require: - - 'Validate with Node v14.17.0' - - 'Validate with Node v16.13.0' + - 'Validate with Node v16.17.0' + - 'Validate with Node v18.12.0' merge: require: - - 'Validate with Node v14.17.0' - - 'Validate with Node v16.13.0' + - 'Validate with Node v16.17.0' + - 'Validate with Node v18.12.0' ``` + +The `rollup.config.mjs` for some monorepo packages. This should match the minimum supported version. diff --git a/documentation/guides/migrating-from-v10-to-v11.md b/documentation/guides/migrating-from-v10-to-v11.md new file mode 100644 index 00000000000..cb130d0772b --- /dev/null +++ b/documentation/guides/migrating-from-v10-to-v11.md @@ -0,0 +1,45 @@ +# Migrating from v10 to v11 + +Polaris v11.0.0 ([full release notes](https://github.com/Shopify/polaris/releases/tag/v11.0.0)) features... + +## Table of Contents + +- [Node support](#node-support) +- [Components](#components) + - [Removed deprecated Collapsible argument](#removed-deprecated-collapsible-argument) + - [Removed KonamiCode component](#removed-konamicode-component) +- [Tokens](#tokens) + +## Node support + +NodeJS version 14 is no longer supported. NodeJS 18 is recommended and 16 is the minimum supported version. + +## React support + +React version 16 and 17 is no longer supported. React 18 is the minimum supported version. + +## Webpack support + +Webpack version 4 is no longer supported. Webpack 5 is the minimum supported version. + +## TypeScript + +Built types in `@shopify/polaris` have moved from `build/ts/latest` to `build/ts`. + +**Legacy TypeScript Support** + +Polaris no longer supports multiple versions of TypeScript with downlevel-dts. Polaris only builds one set of types based on the current version of TypeScript in the project. + +## Components + +### Removed deprecated Collapsible argument + +We've removed the following deprecated prop from the Collapsible component: + +`- preventMeasuringOnChildrenUpdate?: boolean;` + +### Removed KonamiCode component + +We are removing low usage components from Polaris. We love fun but we also want to ensure we are shipping exactly what our users need. If you want to use this in your project feel free to copy the [component sourcecode](https://github.com/Shopify/polaris/blob/%40shopify/polaris%4010.24.0/polaris-react/src/components/KonamiCode/KonamiCode.tsx). + +## Tokens diff --git a/package.json b/package.json index f8e86278e48..4f322b1a1ee 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": true, "engines": { - "node": "^14.17.0 || ^16.13.0" + "node": "^16.17.0 || >=18.12.0" }, "workspaces": { "packages": [ @@ -44,21 +44,23 @@ "postinstall": "patch-package" }, "devDependencies": { - "@babel/core": "^7.15.0", - "@babel/node": "^7.14.9", + "@babel/core": "^7.20.12", + "@babel/node": "^7.20.7", + "@babel/preset-env": "^7.16.4", + "@babel/preset-react": "^7.16.0", + "@babel/preset-typescript": "^7.18.6", "@changesets/changelog-github": "^0.4.4", "@changesets/cli": "^2.23.0", "@changesets/get-release-plan": "^3.0.14", "@next/eslint-plugin-next": "^12.1.4", - "@rollup/plugin-babel": "^5.3.1", - "@rollup/plugin-commonjs": "^21.1.0", - "@rollup/plugin-image": "^2.0.5", - "@rollup/plugin-json": "^4.1.0", - "@rollup/plugin-node-resolve": "^13.2.1", - "@rollup/plugin-replace": "^2.3.3", - "@rollup/plugin-virtual": "^2.0.3", - "@rollup/pluginutils": "^4.1.0", - "@shopify/babel-preset": "^24.1.2", + "@rollup/plugin-babel": "^6.0.3", + "@rollup/plugin-commonjs": "^24.0.1", + "@rollup/plugin-image": "^3.0.2", + "@rollup/plugin-json": "^6.0.0", + "@rollup/plugin-node-resolve": "^15.0.1", + "@rollup/plugin-replace": "^5.0.2", + "@rollup/plugin-virtual": "^3.0.1", + "@rollup/pluginutils": "^5.0.2", "@shopify/cli": "^3.10.1", "@shopify/eslint-plugin": "^42.0.1", "@shopify/prettier-config": "^1.1.2", @@ -66,7 +68,8 @@ "@shopify/typescript-configs": "^5.1.0", "@size-limit/preset-small-lib": "^5.0.3", "@types/jest": "^27.5.1", - "downlevel-dts": "^0.6.0", + "@types/node": "^18.11.18", + "babel-loader": "^9.1.2", "eslint": "^8.3.0", "execa": "^5.0.0", "jest": "^27.5.1", @@ -76,13 +79,13 @@ "patch-package": "^6.4.7", "postinstall-postinstall": "^2.1.0", "prettier": "^2.5.0", - "rollup": "^2.70.2", - "rollup-plugin-node-externals": "^4.0.0", + "rollup": "^3.12.0", + "rollup-plugin-node-externals": "^5.1.0", "size-limit": "^5.0.3", "stylelint": "^14.15.0", "ts-node": "^10.7.0", "turbo": "^1.2.8", - "typescript": "^4.6.3" + "typescript": "^4.9.3" }, "prettier": "@shopify/prettier-config", "size-limit": [ diff --git a/polaris-cli/package.json b/polaris-cli/package.json index 322454900e4..16d910b1306 100644 --- a/polaris-cli/package.json +++ b/polaris-cli/package.json @@ -26,12 +26,9 @@ "@oclif/core": "^1.13.10", "@shopify/polaris-migrator": "^0.15.1" }, - "devDependencies": { - "typescript": "^4.7.4" - }, "engine-strict": true, "engines": { - "node": ">=14.13.1" + "node": "^16.17.0 || >=18.12.0" }, "os": [ "darwin", diff --git a/polaris-for-vscode/package.json b/polaris-for-vscode/package.json index 988c7412feb..ff483c8983d 100644 --- a/polaris-for-vscode/package.json +++ b/polaris-for-vscode/package.json @@ -20,7 +20,8 @@ "shopify" ], "engines": { - "vscode": "^1.64.0" + "vscode": "^1.64.0", + "node": "^16.17.0 || >=18.12.0" }, "categories": [ "Other" @@ -43,7 +44,6 @@ }, "devDependencies": { "@shopify/polaris-tokens": "^6.8.0", - "@types/node": "14.x", "@types/vscode": "^1.64.0", "@vscode/test-electron": "^2.1.2", "globby": "^11.1.0", diff --git a/polaris-icons/package.json b/polaris-icons/package.json index e9e7198ee5d..cfdc2edcc24 100644 --- a/polaris-icons/package.json +++ b/polaris-icons/package.json @@ -13,6 +13,9 @@ ] } }, + "engines": { + "node": "^16.17.0 || >=18.12.0" + }, "scripts": { "build": "rollup -c", "dev": "rollup -c -w", diff --git a/polaris-icons/rollup.config.mjs b/polaris-icons/rollup.config.mjs index d0815f2729b..eee9221dd27 100644 --- a/polaris-icons/rollup.config.mjs +++ b/polaris-icons/rollup.config.mjs @@ -222,6 +222,11 @@ export default [ interop, entryFileNames: '[name].js', chunkFileNames: '[name].js', + manualChunks: (id) => { + if (id.startsWith(iconBasePath)) { + return id.replace(iconBasePath, 'icons/'); + } + }, }, { dir: 'dist', @@ -229,18 +234,15 @@ export default [ interop, entryFileNames: '[name].mjs', chunkFileNames: '[name].mjs', + manualChunks: (id) => { + if (id.startsWith(iconBasePath)) { + return id.replace(iconBasePath, 'icons/'); + } + }, }, ], - manualChunks: (id) => { - // Generate distinct chunks for each icon - // This allows consuming apps to split up the icons into multiple subchunks - // containing a few icons each instead of always having to put every icon - // into a single shared chunk - if (id.startsWith(iconBasePath)) { - return id.replace(iconBasePath, 'icons/'); - } - }, - external: ['react'], + + external: ['react', 'react/jsx-runtime'], onwarn: (warning, warn) => { // Unresolved imports means Rollup couldn't find an import, possibly because // we made a typo in the file name. Fail the build in that case so we know diff --git a/polaris-migrator/package.json b/polaris-migrator/package.json index 930096bdc28..4ae011d7add 100644 --- a/polaris-migrator/package.json +++ b/polaris-migrator/package.json @@ -6,6 +6,9 @@ "author": "Shopify ", "homepage": "https://polaris.shopify.com", "repository": "https://github.com/Shopify/polaris", + "engines": { + "node": "^16.17.0 || >=18.12.0" + }, "bugs": { "url": "https://github.com/Shopify/polaris/issues" }, @@ -48,10 +51,6 @@ "devDependencies": { "@types/is-git-clean": "^1.1.0", "@types/jscodeshift": "^0.11.5", - "@rollup/plugin-babel": "^5.3.1", - "@rollup/plugin-commonjs": "^22.0.2", - "@rollup/plugin-json": "^4.1.0", - "@rollup/plugin-node-resolve": "^13.3.0", "@shopify/polaris": "^10.35.0", "plop": "^3.1.1", "plop-dir": "^0.0.5", diff --git a/polaris-migrator/rollup.config.mjs b/polaris-migrator/rollup.config.mjs index 7590ff5f94f..5785b04448d 100644 --- a/polaris-migrator/rollup.config.mjs +++ b/polaris-migrator/rollup.config.mjs @@ -21,14 +21,14 @@ export default { output: [ { format: /** @type {const} */ ('cjs'), - entryFileNames: '[name][assetExtname].js', + entryFileNames: '[name].js', dir: path.dirname(pkg.main), preserveModules: true, exports: 'auto', }, { format: /** @type {const} */ ('esm'), - entryFileNames: '[name][assetExtname].mjs', + entryFileNames: '[name].mjs', dir: path.dirname(pkg.module), preserveModules: true, }, @@ -45,7 +45,7 @@ export default { include: ['src/**/*'], babelHelpers: 'bundled', envName: 'production', - targets: 'node 14.13', + targets: 'node 16.17.0', }), json({compact: true}), ], diff --git a/polaris-migrator/src/migrations/react-rename-component-prop/tests/react-rename-component-prop.input.tsx b/polaris-migrator/src/migrations/react-rename-component-prop/tests/react-rename-component-prop.input.tsx index 4be474e3865..843f786e0f5 100644 --- a/polaris-migrator/src/migrations/react-rename-component-prop/tests/react-rename-component-prop.input.tsx +++ b/polaris-migrator/src/migrations/react-rename-component-prop/tests/react-rename-component-prop.input.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - interface MyComponentProps { prop?: string; newProp?: string; diff --git a/polaris-migrator/src/migrations/react-rename-component-prop/tests/react-rename-component-prop.output.tsx b/polaris-migrator/src/migrations/react-rename-component-prop/tests/react-rename-component-prop.output.tsx index 9305ddb375b..d4ead638db8 100644 --- a/polaris-migrator/src/migrations/react-rename-component-prop/tests/react-rename-component-prop.output.tsx +++ b/polaris-migrator/src/migrations/react-rename-component-prop/tests/react-rename-component-prop.output.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - interface MyComponentProps { prop?: string; newProp?: string; diff --git a/polaris-migrator/src/migrations/react-rename-component/tests/react-rename-component.input.tsx b/polaris-migrator/src/migrations/react-rename-component/tests/react-rename-component.input.tsx index 278211d8fdf..58709cfbcb7 100644 --- a/polaris-migrator/src/migrations/react-rename-component/tests/react-rename-component.input.tsx +++ b/polaris-migrator/src/migrations/react-rename-component/tests/react-rename-component.input.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {Card} from '@shopify/polaris'; const MyCard = Card; diff --git a/polaris-migrator/src/migrations/react-rename-component/tests/react-rename-component.output.tsx b/polaris-migrator/src/migrations/react-rename-component/tests/react-rename-component.output.tsx index 137f73424ef..8ff847a51e0 100644 --- a/polaris-migrator/src/migrations/react-rename-component/tests/react-rename-component.output.tsx +++ b/polaris-migrator/src/migrations/react-rename-component/tests/react-rename-component.output.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {LegacyCard} from '@shopify/polaris'; const MyCard = LegacyCard; diff --git a/polaris-migrator/src/migrations/react-rename-component/tests/react-rename-stack-component.input.tsx b/polaris-migrator/src/migrations/react-rename-component/tests/react-rename-stack-component.input.tsx index 60830ff037f..eb968d2f8e2 100644 --- a/polaris-migrator/src/migrations/react-rename-component/tests/react-rename-stack-component.input.tsx +++ b/polaris-migrator/src/migrations/react-rename-component/tests/react-rename-stack-component.input.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {Stack} from '@shopify/polaris'; const MyStack = Stack; diff --git a/polaris-migrator/src/migrations/react-rename-component/tests/react-rename-stack-component.output.tsx b/polaris-migrator/src/migrations/react-rename-component/tests/react-rename-stack-component.output.tsx index ab49d74d730..72b1861a027 100644 --- a/polaris-migrator/src/migrations/react-rename-component/tests/react-rename-stack-component.output.tsx +++ b/polaris-migrator/src/migrations/react-rename-component/tests/react-rename-stack-component.output.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {LegacyStack} from '@shopify/polaris'; const MyStack = LegacyStack; diff --git a/polaris-migrator/src/migrations/react-rename-component/tests/rename-prop-types.input.tsx b/polaris-migrator/src/migrations/react-rename-component/tests/rename-prop-types.input.tsx index d80b696d34e..94bf07ba2ea 100644 --- a/polaris-migrator/src/migrations/react-rename-component/tests/rename-prop-types.input.tsx +++ b/polaris-migrator/src/migrations/react-rename-component/tests/rename-prop-types.input.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {CardProps} from '@shopify/polaris'; export interface MyCardProps extends CardProps {} diff --git a/polaris-migrator/src/migrations/react-rename-component/tests/rename-prop-types.output.tsx b/polaris-migrator/src/migrations/react-rename-component/tests/rename-prop-types.output.tsx index bd6065aee0c..4f4e35e5b11 100644 --- a/polaris-migrator/src/migrations/react-rename-component/tests/rename-prop-types.output.tsx +++ b/polaris-migrator/src/migrations/react-rename-component/tests/rename-prop-types.output.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {LegacyCardProps} from '@shopify/polaris'; export interface MyCardProps extends LegacyCardProps {} diff --git a/polaris-migrator/src/migrations/react-rename-component/tests/renamed-available-identifier.input.tsx b/polaris-migrator/src/migrations/react-rename-component/tests/renamed-available-identifier.input.tsx index 3b0a83177a4..e8429fb904e 100644 --- a/polaris-migrator/src/migrations/react-rename-component/tests/renamed-available-identifier.input.tsx +++ b/polaris-migrator/src/migrations/react-rename-component/tests/renamed-available-identifier.input.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {Card as PolarisCard} from '@shopify/polaris'; const MyCard = PolarisCard; diff --git a/polaris-migrator/src/migrations/react-rename-component/tests/renamed-available-identifier.output.tsx b/polaris-migrator/src/migrations/react-rename-component/tests/renamed-available-identifier.output.tsx index 535ef3cf617..318feb501b7 100644 --- a/polaris-migrator/src/migrations/react-rename-component/tests/renamed-available-identifier.output.tsx +++ b/polaris-migrator/src/migrations/react-rename-component/tests/renamed-available-identifier.output.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {Card as PolarisCard} from '@shopify/polaris'; const MyCard = PolarisCard; diff --git a/polaris-migrator/src/migrations/react-rename-component/tests/renamed-available-jsx.input.tsx b/polaris-migrator/src/migrations/react-rename-component/tests/renamed-available-jsx.input.tsx index f13016e992a..025a37d771b 100644 --- a/polaris-migrator/src/migrations/react-rename-component/tests/renamed-available-jsx.input.tsx +++ b/polaris-migrator/src/migrations/react-rename-component/tests/renamed-available-jsx.input.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {Card as PolarisCard} from '@shopify/polaris'; const MyCard = PolarisCard; diff --git a/polaris-migrator/src/migrations/react-rename-component/tests/renamed-available-jsx.output.tsx b/polaris-migrator/src/migrations/react-rename-component/tests/renamed-available-jsx.output.tsx index fdd21ea489b..f1216f9f5f5 100644 --- a/polaris-migrator/src/migrations/react-rename-component/tests/renamed-available-jsx.output.tsx +++ b/polaris-migrator/src/migrations/react-rename-component/tests/renamed-available-jsx.output.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {Card as PolarisCard} from '@shopify/polaris'; const MyCard = PolarisCard; diff --git a/polaris-migrator/src/migrations/react-rename-component/tests/renamed-import.input.tsx b/polaris-migrator/src/migrations/react-rename-component/tests/renamed-import.input.tsx index db747809228..f2382fd31d8 100644 --- a/polaris-migrator/src/migrations/react-rename-component/tests/renamed-import.input.tsx +++ b/polaris-migrator/src/migrations/react-rename-component/tests/renamed-import.input.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {Card as PolarisCard} from '@shopify/polaris'; const MyCard = PolarisCard; diff --git a/polaris-migrator/src/migrations/react-rename-component/tests/renamed-import.output.tsx b/polaris-migrator/src/migrations/react-rename-component/tests/renamed-import.output.tsx index 7e04fd4be1c..bb7d8a4f6fe 100644 --- a/polaris-migrator/src/migrations/react-rename-component/tests/renamed-import.output.tsx +++ b/polaris-migrator/src/migrations/react-rename-component/tests/renamed-import.output.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {LegacyCard} from '@shopify/polaris'; const MyCard = LegacyCard; diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-all.input.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-all.input.tsx index d74f6d01b66..63b4e8a6eba 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-all.input.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-all.input.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { Caption, DisplayText, diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-all.output.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-all.output.tsx index 92ddf39c233..17d2b01af33 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-all.output.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-all.output.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {Text, InlineCode} from '@shopify/polaris'; export function App() { diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-identifier.input.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-identifier.input.tsx index ac71d0e75f7..37d61c1a226 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-identifier.input.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-identifier.input.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {Caption, DisplayText} from '@shopify/polaris'; export function App() { diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-identifier.output.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-identifier.output.tsx index 4ad56081887..dea5b53fe7d 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-identifier.output.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-identifier.output.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { /* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */ /* Replace with: Text */ diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-props-invalid.input.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-props-invalid.input.tsx index c7a5847f131..dbbdc7d5d86 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-props-invalid.input.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-props-invalid.input.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { Caption, DisplayText, diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-props-invalid.output.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-props-invalid.output.tsx index 80f96e965ac..fb9e8ef8fd5 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-props-invalid.output.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-props-invalid.output.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { /* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */ /* Replace with: Text */ diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-props-type.input.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-props-type.input.tsx index f82c7899701..ea764f3253b 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-props-type.input.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-props-type.input.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {CaptionProps} from '@shopify/polaris'; import {Caption, DisplayText} from '@shopify/polaris'; diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-props-type.output.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-props-type.output.tsx index 24f6a112286..b3377530a61 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-props-type.output.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/remove-imports-partial-props-type.output.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type { /* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */ /* Replace with: TextProps */ diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/v10-react-replace-text-components.input.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/v10-react-replace-text-components.input.tsx index e82264d9e71..d85d074214d 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/v10-react-replace-text-components.input.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/v10-react-replace-text-components.input.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {TextStyleProps} from '@shopify/polaris'; import { DisplayText, diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/v10-react-replace-text-components.output.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/v10-react-replace-text-components.output.tsx index 832b1862710..4027187c0ce 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/v10-react-replace-text-components.output.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/v10-react-replace-text-components.output.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type { /* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */ /* Replace with: TextProps */ diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-component-name.input.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-component-name.input.tsx index bc45c624cf4..a2ea1d24cdb 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-component-name.input.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-component-name.input.tsx @@ -1,13 +1,5 @@ // @ts-nocheck -import React from 'react'; -import { - DisplayText, - Caption, - Heading, - Subheading, - TextStyle, - VisuallyHidden, -} from '@shopify/polaris'; +import { DisplayText, Caption, Heading, Subheading, TextStyle, VisuallyHidden } from '@shopify/polaris'; export function App() { return ( diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-component-name.output.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-component-name.output.tsx index 14bce256408..e97368adaf0 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-component-name.output.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-component-name.output.tsx @@ -1,13 +1,5 @@ // @ts-nocheck -import React from 'react'; -import { - DisplayText, - Caption, - Subheading, - TextStyle, - VisuallyHidden, - Text, -} from '@shopify/polaris'; +import { DisplayText, Caption, Subheading, TextStyle, VisuallyHidden, Text } from '@shopify/polaris'; export function App() { return ( diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-other-component-and-other-component-props.input.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-other-component-and-other-component-props.input.tsx index c9363744f98..d99c583c5c6 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-other-component-and-other-component-props.input.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-other-component-and-other-component-props.input.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {HeadingProps} from '@shopify/polaris'; import {Subheading} from '@shopify/polaris'; diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-other-component-and-other-component-props.output.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-other-component-and-other-component-props.output.tsx index 75d5576ac52..1e32fcb8f39 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-other-component-and-other-component-props.output.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-other-component-and-other-component-props.output.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type { /* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */ /* Replace with: TextProps */ diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-display-text.input.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-display-text.input.tsx index 2459942aa53..d5246c426ff 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-display-text.input.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-display-text.input.tsx @@ -1,7 +1,5 @@ // @ts-nocheck -import React from 'react'; - -import {DisplayText} from '../DisplayText'; +import { DisplayText } from '../DisplayText'; export function App() { return Display text; diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-display-text.output.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-display-text.output.tsx index 0b2165fa42b..5ac90e4d2ee 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-display-text.output.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-display-text.output.tsx @@ -1,7 +1,5 @@ // @ts-nocheck -import React from 'react'; - -import {Text} from '../Text'; +import { Text } from '../Text'; export function App() { return ( diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-other-component-and-other-component-props.input.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-other-component-and-other-component-props.input.tsx index e8b245df74d..1c2eb4e315a 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-other-component-and-other-component-props.input.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-other-component-and-other-component-props.input.tsx @@ -1,7 +1,5 @@ // @ts-nocheck -import React from 'react'; - -import type {HeadingProps} from '../Heading'; +import type { HeadingProps } from '../Heading'; import {TextStyle} from '../TextStyle'; const MyHeading = (_props: HeadingProps) => { diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-other-component-and-other-component-props.output.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-other-component-and-other-component-props.output.tsx index 96fdf6212a6..e22ca02456b 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-other-component-and-other-component-props.output.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-other-component-and-other-component-props.output.tsx @@ -1,6 +1,4 @@ // @ts-nocheck -import React from 'react'; - import type { /* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */ /* Replace with: TextProps */ diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-text-style-props.input.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-text-style-props.input.tsx index 538adb29ef6..9d266bfbe75 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-text-style-props.input.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-text-style-props.input.tsx @@ -1,7 +1,5 @@ // @ts-nocheck -import React from 'react'; - -import type {TextStyleProps} from '../TextStyle'; +import type { TextStyleProps } from '../TextStyle'; const MyTextStyle = (_props: TextStyleProps) => { return null; diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-text-style-props.output.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-text-style-props.output.tsx index 6e1d5eaad6a..363e26b1414 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-text-style-props.output.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative-text-style-props.output.tsx @@ -1,6 +1,4 @@ // @ts-nocheck -import React from 'react'; - import type { /* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */ /* Replace with: TextProps */ diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative.input.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative.input.tsx index 26f7d52c423..d8f140f0829 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative.input.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative.input.tsx @@ -1,7 +1,5 @@ // @ts-nocheck -import React from 'react'; - -import {DisplayText} from '../DisplayText'; +import { DisplayText } from '../DisplayText'; import {Heading} from '../Heading'; import {Subheading} from '../Subheading'; import {Caption} from '../Caption'; diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative.output.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative.output.tsx index 38cea8f97a9..1c6bfecd6b9 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative.output.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-relative.output.tsx @@ -1,6 +1,4 @@ // @ts-nocheck -import React from 'react'; - import { /* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */ /* Replace with: Text */ diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-text-style-props.input.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-text-style-props.input.tsx index 269155605f5..33e5f69b91a 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-text-style-props.input.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-text-style-props.input.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {TextStyleProps} from '@shopify/polaris'; const MyTextStyle = (_props: TextStyleProps) => { diff --git a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-text-style-props.output.tsx b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-text-style-props.output.tsx index 6e35285fdbe..7dd170e17ef 100644 --- a/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-text-style-props.output.tsx +++ b/polaris-migrator/src/migrations/v10-react-replace-text-components/tests/with-text-style-props.output.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type { /* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */ /* Replace with: TextProps */ diff --git a/polaris-migrator/src/migrations/v11-react-update-page-breadcrumbs/tests/v11-react-update-page-breadcrumbs.input.tsx b/polaris-migrator/src/migrations/v11-react-update-page-breadcrumbs/tests/v11-react-update-page-breadcrumbs.input.tsx index 9c1bb22d4ca..3aa99181da4 100644 --- a/polaris-migrator/src/migrations/v11-react-update-page-breadcrumbs/tests/v11-react-update-page-breadcrumbs.input.tsx +++ b/polaris-migrator/src/migrations/v11-react-update-page-breadcrumbs/tests/v11-react-update-page-breadcrumbs.input.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {Page} from '@shopify/polaris'; export function App({ diff --git a/polaris-migrator/src/migrations/v11-react-update-page-breadcrumbs/tests/v11-react-update-page-breadcrumbs.output.tsx b/polaris-migrator/src/migrations/v11-react-update-page-breadcrumbs/tests/v11-react-update-page-breadcrumbs.output.tsx index 301c99ebc69..6004a42dd50 100644 --- a/polaris-migrator/src/migrations/v11-react-update-page-breadcrumbs/tests/v11-react-update-page-breadcrumbs.output.tsx +++ b/polaris-migrator/src/migrations/v11-react-update-page-breadcrumbs/tests/v11-react-update-page-breadcrumbs.output.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {Page} from '@shopify/polaris'; export function App({ diff --git a/polaris-migrator/tsconfig.json b/polaris-migrator/tsconfig.json index 6051d2576fb..661fd5a6b96 100644 --- a/polaris-migrator/tsconfig.json +++ b/polaris-migrator/tsconfig.json @@ -6,7 +6,7 @@ "emitDeclarationOnly": true, "outDir": "dist/types", "rootDir": "src", - "jsx": "react", + "jsx": "react-jsx", "types": ["node", "jest"] }, "include": ["src"], diff --git a/polaris-react/.storybook/GridOverlay/GridOverlay.tsx b/polaris-react/.storybook/GridOverlay/GridOverlay.tsx index 3ed4131a04e..781e80e2b92 100644 --- a/polaris-react/.storybook/GridOverlay/GridOverlay.tsx +++ b/polaris-react/.storybook/GridOverlay/GridOverlay.tsx @@ -1,4 +1,4 @@ -import React, {useState} from 'react'; +import {useState} from 'react'; // eslint-disable-next-line import/no-deprecated import {EventListener} from '../../src'; import {classNames} from '../../src/utilities/css'; diff --git a/polaris-react/.storybook/RenderPerformanceProfiler/RenderPerformanceProfiler.tsx b/polaris-react/.storybook/RenderPerformanceProfiler/RenderPerformanceProfiler.tsx index 4f757177afc..fda404a7173 100644 --- a/polaris-react/.storybook/RenderPerformanceProfiler/RenderPerformanceProfiler.tsx +++ b/polaris-react/.storybook/RenderPerformanceProfiler/RenderPerformanceProfiler.tsx @@ -1,4 +1,4 @@ -import React, {PropsWithChildren} from 'react'; +import { Profiler, PropsWithChildren } from 'react'; interface Data { id: string; @@ -34,7 +34,7 @@ export const RenderPerformanceProfiler = ({ } return ( - { const data = { @@ -48,6 +48,6 @@ export const RenderPerformanceProfiler = ({ }} > {children} - + ); }; diff --git a/polaris-react/.storybook/manager.js b/polaris-react/.storybook/manager.js index 92a2a0dfc59..b4098fb8855 100644 --- a/polaris-react/.storybook/manager.js +++ b/polaris-react/.storybook/manager.js @@ -1,4 +1,3 @@ -import React from 'react'; import {AddonPanel, ArgsTable} from '@storybook/components'; import {addons, types} from '@storybook/addons'; import {useGlobals} from '@storybook/api'; diff --git a/polaris-react/.storybook/preview.js b/polaris-react/.storybook/preview.js index 9c3746309b4..37711c5cdb0 100644 --- a/polaris-react/.storybook/preview.js +++ b/polaris-react/.storybook/preview.js @@ -1,4 +1,4 @@ -import React from 'react'; +import { StrictMode, Fragment } from 'react'; import {AppProvider} from '../src'; import enTranslations from '../locales/en.json'; @@ -9,7 +9,7 @@ import {breakpoints} from '@shopify/polaris-tokens'; function StrictModeDecorator(Story, context) { const {strictMode} = context.globals; - const Wrapper = strictMode ? React.StrictMode : React.Fragment; + const Wrapper = strictMode ? StrictMode : Fragment; return ( @@ -45,7 +45,7 @@ function GridOverlayDecorator(Story, context) { function ReactRenderProfiler(Story, context) { const {profiler} = context.globals; - const Wrapper = profiler ? RenderPerformanceProfiler : React.Fragment; + const Wrapper = profiler ? RenderPerformanceProfiler : Fragment; const props = profiler ? {id: context.id, kind: context.kind} : {}; return ( diff --git a/polaris-react/package.json b/polaris-react/package.json index c08dfe0d1f7..3fbd4ebe6ab 100644 --- a/polaris-react/package.json +++ b/polaris-react/package.json @@ -10,6 +10,9 @@ "bugs": { "url": "https://github.com/Shopify/polaris/issues" }, + "engines": { + "node": "^16.17.0 || >=18.12.0" + }, "publishConfig": { "access": "public", "@shopify:registry": "https://registry.npmjs.org" @@ -36,18 +39,10 @@ "main": "build/cjs/index.js", "module": "build/esm/index.js", "esnext": "build/esnext/index.esnext", - "types": "build/ts/latest/src/index.d.ts", - "typesVersions": { - "<4.0": { - "build/types/latest/*": [ - "build/ts/3.4/*" - ] - } - }, + "types": "build/ts/src/index.d.ts", "scripts": { - "build": "run-s build:types build:types-downlevel build:js build:validate", + "build": "run-s build:types build:js build:validate", "build:types": "tsc -b", - "build:types-downlevel": "downlevel-dts './build/ts/latest' './build/ts/3.4'", "build:js": "rollup -c", "build:validate": "node scripts/build-validate.js", "dev": "yarn run storybook", @@ -71,14 +66,11 @@ "react-transition-group": "^4.4.2" }, "peerDependencies": { - "react": "^16.14.0 || ^17.0.0 || ^18.0.0", - "react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0" + "react": "^18.0.0", + "react-dom": "^18.0.0" }, "devDependencies": { - "@babel/core": "^7.15.0", - "@babel/node": "^7.14.9", "@changesets/get-release-plan": "^3.0.13", - "@shopify/browserslist-config": "^3.0.0", "@shopify/jest-dom-mocks": "^3.0.5", "@shopify/postcss-plugin": "^5.0.1", "@shopify/react-testing": "^4.1.0", @@ -89,11 +81,8 @@ "@storybook/builder-webpack5": "^6.5.12", "@storybook/manager-webpack5": "^6.5.12", "@storybook/react": "^6.5.12", - "@types/node": "^16.11.11", "@types/react": "^18.0.15", "@types/react-dom": "^18.0.6", - "babel-core": "7.0.0-bridge.0", - "babel-loader": "^8.1.0", "change-case": "^3.1.0", "chromatic": "^6.5.4", "create-file-webpack": "^1.0.2", diff --git a/polaris-react/playground/DetailsPage.tsx b/polaris-react/playground/DetailsPage.tsx index a99ac21fb30..375abd2cf18 100644 --- a/polaris-react/playground/DetailsPage.tsx +++ b/polaris-react/playground/DetailsPage.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useRef, useState} from 'react'; +import { useCallback, useRef, useState } from 'react'; import { AnalyticsMajor, AppsMajor, @@ -528,8 +528,7 @@ export function DetailsPage() { alt={file.name} source={ validImageTypes.indexOf(file.type) > 0 - ? // eslint-disable-next-line node/no-unsupported-features/node-builtins - URL.createObjectURL(file) + ? URL.createObjectURL(file) : 'https://cdn.shopify.com/s/files/1/0757/9955/files/New_Post.png?12678548500147524304' } /> @@ -548,7 +547,7 @@ export function DetailsPage() { const actualPageMarkup = ( Success badge} primaryAction={{ diff --git a/polaris-react/playground/KitchenSink.tsx b/polaris-react/playground/KitchenSink.tsx index eeb53f4afaa..770861903cb 100644 --- a/polaris-react/playground/KitchenSink.tsx +++ b/polaris-react/playground/KitchenSink.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {RenderPerformanceProfiler} from '../.storybook/RenderPerformanceProfiler'; interface Stories { diff --git a/polaris-react/playground/Playground.tsx b/polaris-react/playground/Playground.tsx index 355f6b984f2..6009e657e69 100644 --- a/polaris-react/playground/Playground.tsx +++ b/polaris-react/playground/Playground.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {Page} from '../src'; export function Playground() { diff --git a/polaris-react/rollup.config.mjs b/polaris-react/rollup.config.mjs index 34ca161cb6f..150534584fd 100644 --- a/polaris-react/rollup.config.mjs +++ b/polaris-react/rollup.config.mjs @@ -33,7 +33,6 @@ function generateConfig({output, targets, stylesConfig}) { // Options that may be present on the `babelConfig` object but // we want to override envName: 'production', - // @ts-expect-error targets is a valid babel option but @types/babel__core doesn't know that yet targets, }), replace({ @@ -54,7 +53,7 @@ function generateConfig({output, targets, stylesConfig}) { /** @type {import('rollup').RollupOptions} */ export default [ generateConfig({ - targets: 'extends @shopify/browserslist-config, node 12.20', + targets: [...pkg.browserslist, 'node 16.17.0'], stylesConfig: { mode: 'standalone', output: 'styles.css', @@ -69,14 +68,14 @@ export default [ format: 'cjs', dir: path.dirname(pkg.main), preserveModules: true, - entryFileNames: '[name][assetExtname].js', + entryFileNames: '[name].js', exports: 'named', }, { format: 'esm', dir: path.dirname(pkg.module), preserveModules: true, - entryFileNames: '[name][assetExtname].js', + entryFileNames: '[name].js', }, ], }), @@ -95,7 +94,7 @@ export default [ format: 'esm', dir: path.dirname(pkg.esnext), preserveModules: true, - entryFileNames: '[name][assetExtname].esnext', + entryFileNames: '[name].esnext', }, ], }), diff --git a/polaris-react/scripts/build-validate.js b/polaris-react/scripts/build-validate.js index 4b2dcf87612..c6654c9129b 100644 --- a/polaris-react/scripts/build-validate.js +++ b/polaris-react/scripts/build-validate.js @@ -1,4 +1,3 @@ -// eslint-disable-next-line node/no-unsupported-features/node-builtins const assert = require('assert').strict; const fs = require('fs'); @@ -83,9 +82,7 @@ function validateEsNextBuild() { } function validateAncillaryOutput() { - assert.ok(fs.existsSync('./build/ts/latest/src/index.d.ts')); - // Downleveled for consumers on older TypeScript versions - assert.ok(fs.existsSync('./build/ts/3.4/src/index.d.ts')); + assert.ok(fs.existsSync('./build/ts/src/index.d.ts')); } function validateVersionReplacement() { diff --git a/polaris-react/src/components/AccountConnection/AccountConnection.stories.tsx b/polaris-react/src/components/AccountConnection/AccountConnection.stories.tsx index 3a739793182..ea3f669d9b1 100644 --- a/polaris-react/src/components/AccountConnection/AccountConnection.stories.tsx +++ b/polaris-react/src/components/AccountConnection/AccountConnection.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useState} from 'react'; +import { useCallback, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import {AccountConnection, Link} from '@shopify/polaris'; diff --git a/polaris-react/src/components/AccountConnection/AccountConnection.tsx b/polaris-react/src/components/AccountConnection/AccountConnection.tsx index 67eb3117682..7996539a66a 100644 --- a/polaris-react/src/components/AccountConnection/AccountConnection.tsx +++ b/polaris-react/src/components/AccountConnection/AccountConnection.tsx @@ -1,14 +1,12 @@ -import React from 'react'; - import type {Action} from '../../types'; import {Avatar} from '../Avatar'; import {buttonFrom} from '../Button'; import {SettingAction} from '../SettingAction'; -import {AlphaCard} from '../AlphaCard'; +import {Card} from '../Card'; import {Box} from '../Box'; import {Inline} from '../Inline'; import {Text} from '../Text'; -import {AlphaStack} from '../AlphaStack'; +import {Stack} from '../Stack'; export interface AccountConnectionProps { /** Content to display as title */ @@ -69,17 +67,17 @@ export function AccountConnection({ : null; return ( - + {avatarMarkup} - + {titleMarkup} {detailsMarkup} - + {termsOfServiceMarkup} - + ); } diff --git a/polaris-react/src/components/AccountConnection/tests/AccountConnection.test.tsx b/polaris-react/src/components/AccountConnection/tests/AccountConnection.test.tsx index aac5109963c..f7591d9b7e4 100644 --- a/polaris-react/src/components/AccountConnection/tests/AccountConnection.test.tsx +++ b/polaris-react/src/components/AccountConnection/tests/AccountConnection.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {matchMedia} from '@shopify/jest-dom-mocks'; diff --git a/polaris-react/src/components/ActionList/ActionList.stories.tsx b/polaris-react/src/components/ActionList/ActionList.stories.tsx index f6900faeef7..437778e1c24 100644 --- a/polaris-react/src/components/ActionList/ActionList.stories.tsx +++ b/polaris-react/src/components/ActionList/ActionList.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useState} from 'react'; +import { useCallback, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import { ActionList, diff --git a/polaris-react/src/components/ActionList/ActionList.tsx b/polaris-react/src/components/ActionList/ActionList.tsx index 7ec14e87b69..9c3cfb9c469 100644 --- a/polaris-react/src/components/ActionList/ActionList.tsx +++ b/polaris-react/src/components/ActionList/ActionList.tsx @@ -1,4 +1,4 @@ -import React, {useRef} from 'react'; +import { useRef } from 'react'; import { wrapFocusNextFocusableMenuItem, diff --git a/polaris-react/src/components/ActionList/components/Item/Item.tsx b/polaris-react/src/components/ActionList/components/Item/Item.tsx index 1f13460adf8..82e9d98ce23 100644 --- a/polaris-react/src/components/ActionList/components/Item/Item.tsx +++ b/polaris-react/src/components/ActionList/components/Item/Item.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {classNames} from '../../../../utilities/css'; import type {ActionListItemDescriptor} from '../../../../types'; import {Scrollable} from '../../../Scrollable'; diff --git a/polaris-react/src/components/ActionList/components/Item/tests/Item.test.tsx b/polaris-react/src/components/ActionList/components/Item/tests/Item.test.tsx index 5494718b75d..bea01b66f60 100644 --- a/polaris-react/src/components/ActionList/components/Item/tests/Item.test.tsx +++ b/polaris-react/src/components/ActionList/components/Item/tests/Item.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Item} from '../Item'; diff --git a/polaris-react/src/components/ActionList/components/Section/Section.tsx b/polaris-react/src/components/ActionList/components/Section/Section.tsx index 921d6b83681..3d84749c035 100644 --- a/polaris-react/src/components/ActionList/components/Section/Section.tsx +++ b/polaris-react/src/components/ActionList/components/Section/Section.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {Item} from '../Item'; import {Box} from '../../../Box'; import {Text} from '../../../Text'; diff --git a/polaris-react/src/components/ActionList/components/Section/tests/Section.test.tsx b/polaris-react/src/components/ActionList/components/Section/tests/Section.test.tsx index 90e03ec68d6..f2259961398 100644 --- a/polaris-react/src/components/ActionList/components/Section/tests/Section.test.tsx +++ b/polaris-react/src/components/ActionList/components/Section/tests/Section.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Item} from '../../Item'; diff --git a/polaris-react/src/components/ActionList/tests/ActionList.test.tsx b/polaris-react/src/components/ActionList/tests/ActionList.test.tsx index 14ed6e9cab5..d82dceb53c3 100644 --- a/polaris-react/src/components/ActionList/tests/ActionList.test.tsx +++ b/polaris-react/src/components/ActionList/tests/ActionList.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {ImportMinor, ExportMinor} from '@shopify/polaris-icons'; import {mountWithApp} from 'tests/utilities'; diff --git a/polaris-react/src/components/ActionMenu/ActionMenu.tsx b/polaris-react/src/components/ActionMenu/ActionMenu.tsx index b09fb002bdd..a60263ad00c 100644 --- a/polaris-react/src/components/ActionMenu/ActionMenu.tsx +++ b/polaris-react/src/components/ActionMenu/ActionMenu.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {classNames} from '../../utilities/css'; import type { ActionListSection, diff --git a/polaris-react/src/components/ActionMenu/components/Actions/Actions.tsx b/polaris-react/src/components/ActionMenu/components/Actions/Actions.tsx index 5f7c44b4873..32679e6566e 100644 --- a/polaris-react/src/components/ActionMenu/components/Actions/Actions.tsx +++ b/polaris-react/src/components/ActionMenu/components/Actions/Actions.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useMemo, useRef, useState} from 'react'; +import { useCallback, useMemo, useRef, useState } from 'react'; import type { ActionListItemDescriptor, diff --git a/polaris-react/src/components/ActionMenu/components/Actions/tests/Actions.test.tsx b/polaris-react/src/components/ActionMenu/components/Actions/tests/Actions.test.tsx index 6559b07eeb9..0c9b6b6d4f7 100644 --- a/polaris-react/src/components/ActionMenu/components/Actions/tests/Actions.test.tsx +++ b/polaris-react/src/components/ActionMenu/components/Actions/tests/Actions.test.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useState} from 'react'; +import { useCallback, useState } from 'react'; import {mountWithApp} from 'tests/utilities'; import {ActionMenuProps, ActionMenu} from '../../..'; diff --git a/polaris-react/src/components/ActionMenu/components/MenuGroup/MenuGroup.tsx b/polaris-react/src/components/ActionMenu/components/MenuGroup/MenuGroup.tsx index 5052ed6e5f4..ff1dbadfc47 100644 --- a/polaris-react/src/components/ActionMenu/components/MenuGroup/MenuGroup.tsx +++ b/polaris-react/src/components/ActionMenu/components/MenuGroup/MenuGroup.tsx @@ -1,4 +1,4 @@ -import React, {useCallback} from 'react'; +import { useCallback } from 'react'; import type {ActionListSection, MenuGroupDescriptor} from '../../../../types'; import {ActionList} from '../../../ActionList'; diff --git a/polaris-react/src/components/ActionMenu/components/MenuGroup/tests/MenuGroup.test.tsx b/polaris-react/src/components/ActionMenu/components/MenuGroup/tests/MenuGroup.test.tsx index c47e257866f..9be726c024b 100644 --- a/polaris-react/src/components/ActionMenu/components/MenuGroup/tests/MenuGroup.test.tsx +++ b/polaris-react/src/components/ActionMenu/components/MenuGroup/tests/MenuGroup.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {ActionList} from '../../../../ActionList'; diff --git a/polaris-react/src/components/ActionMenu/components/RollupActions/RollupActions.tsx b/polaris-react/src/components/ActionMenu/components/RollupActions/RollupActions.tsx index b89e6ce59ad..8091d1aeb87 100644 --- a/polaris-react/src/components/ActionMenu/components/RollupActions/RollupActions.tsx +++ b/polaris-react/src/components/ActionMenu/components/RollupActions/RollupActions.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {HorizontalDotsMinor} from '@shopify/polaris-icons'; import type { diff --git a/polaris-react/src/components/ActionMenu/components/RollupActions/tests/RollupActions.test.tsx b/polaris-react/src/components/ActionMenu/components/RollupActions/tests/RollupActions.test.tsx index 5979230dcdc..e4335b7f26f 100644 --- a/polaris-react/src/components/ActionMenu/components/RollupActions/tests/RollupActions.test.tsx +++ b/polaris-react/src/components/ActionMenu/components/RollupActions/tests/RollupActions.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {HorizontalDotsMinor} from '@shopify/polaris-icons'; import {mountWithApp} from 'tests/utilities'; diff --git a/polaris-react/src/components/ActionMenu/components/SecondaryAction/SecondaryAction.tsx b/polaris-react/src/components/ActionMenu/components/SecondaryAction/SecondaryAction.tsx index d3c0c33527c..3ba77a68052 100644 --- a/polaris-react/src/components/ActionMenu/components/SecondaryAction/SecondaryAction.tsx +++ b/polaris-react/src/components/ActionMenu/components/SecondaryAction/SecondaryAction.tsx @@ -1,4 +1,4 @@ -import React, {useEffect, useRef} from 'react'; +import {useEffect, useRef} from 'react'; import {classNames} from '../../../../utilities/css'; import {Tooltip} from '../../../Tooltip'; diff --git a/polaris-react/src/components/ActionMenu/tests/ActionMenu.test.tsx b/polaris-react/src/components/ActionMenu/tests/ActionMenu.test.tsx index 8ff14bcc0c3..6461e3ca8a4 100644 --- a/polaris-react/src/components/ActionMenu/tests/ActionMenu.test.tsx +++ b/polaris-react/src/components/ActionMenu/tests/ActionMenu.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import type { diff --git a/polaris-react/src/components/AfterInitialMount/AfterInitialMount.tsx b/polaris-react/src/components/AfterInitialMount/AfterInitialMount.tsx index 63b7707006f..6e279bd0908 100644 --- a/polaris-react/src/components/AfterInitialMount/AfterInitialMount.tsx +++ b/polaris-react/src/components/AfterInitialMount/AfterInitialMount.tsx @@ -1,4 +1,4 @@ -import React, {ReactNode, useEffect} from 'react'; +import { ReactNode, useEffect } from 'react'; import {useIsAfterInitialMount} from '../../utilities/use-is-after-initial-mount'; diff --git a/polaris-react/src/components/AfterInitialMount/test/AfterInitialMount.test.tsx b/polaris-react/src/components/AfterInitialMount/test/AfterInitialMount.test.tsx index 22a25cf7014..0334bb8eb0b 100644 --- a/polaris-react/src/components/AfterInitialMount/test/AfterInitialMount.test.tsx +++ b/polaris-react/src/components/AfterInitialMount/test/AfterInitialMount.test.tsx @@ -1,4 +1,4 @@ -import React, {useEffect} from 'react'; +import { useEffect } from 'react'; import {mountWithApp} from 'tests/utilities'; import {AfterInitialMount} from '../AfterInitialMount'; diff --git a/polaris-react/src/components/AlphaCard/AlphaCard.stories.tsx b/polaris-react/src/components/AlphaCard/AlphaCard.stories.tsx deleted file mode 100644 index 18c83caf9ec..00000000000 --- a/polaris-react/src/components/AlphaCard/AlphaCard.stories.tsx +++ /dev/null @@ -1,104 +0,0 @@ -import React from 'react'; -import type {ComponentMeta} from '@storybook/react'; -import { - AlphaCard, - AlphaStack, - Bleed, - Box, - Divider, - List, - Text, -} from '@shopify/polaris'; - -export default { - component: AlphaCard, -} as ComponentMeta; - -export function Default() { - return ( - - - - Online store dashboard - -

View a summary of your online store’s performance.

-
-
- ); -} - -export function WithBackgroundSubdued() { - return ( - - - - Online store dashboard - -

View a summary of your online store’s performance.

-
-
- ); -} - -export function WithBorderRadiusRoundedAbove() { - return ( - - - - Online store dashboard - -

View a summary of your online store’s performance.

-
-
- ); -} - -export function WithResponsivePadding() { - return ( - - - - Online store dashboard - -

View a summary of your online store’s performance.

-
-
- ); -} - -export function WithSubduedSection() { - return ( - - - - Staff accounts - - - - Felix Crafford - Ezequiel Manno - - - - - - - - - Deactivated staff accounts - - - Felix Crafford - Ezequiel Manno - - - - - - ); -} diff --git a/polaris-react/src/components/AlphaCard/AlphaCard.tsx b/polaris-react/src/components/AlphaCard/AlphaCard.tsx deleted file mode 100644 index a4a76379985..00000000000 --- a/polaris-react/src/components/AlphaCard/AlphaCard.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import type { - BreakpointsAlias, - ColorsTokenName, - ShapeBorderRadiusScale, - SpacingSpaceScale, -} from '@shopify/polaris-tokens'; -import React from 'react'; - -import {useBreakpoints} from '../../utilities/breakpoints'; -import type {ResponsiveProp} from '../../utilities/css'; -import {Box} from '../Box'; - -type CardBackgroundColorTokenScale = Extract< - ColorsTokenName, - 'surface' | 'surface-subdued' ->; - -type Spacing = ResponsiveProp; - -export interface AlphaCardProps { - children?: React.ReactNode; - /** Background color - * @default 'surface' - */ - background?: CardBackgroundColorTokenScale; - /** The spacing around the card - * @default {xs: '4', sm: '5'} - * @example - * padding='4' - * padding={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}} - */ - padding?: Spacing; - /** Border radius value above a set breakpoint */ - roundedAbove?: BreakpointsAlias; -} - -export const AlphaCard = ({ - children, - background = 'surface', - padding = {xs: '4', sm: '5'}, - roundedAbove, -}: AlphaCardProps) => { - const breakpoints = useBreakpoints(); - const defaultBorderRadius = '2' as ShapeBorderRadiusScale; - - let hasBorderRadius = !roundedAbove; - - if (roundedAbove && breakpoints[`${roundedAbove}Up`]) { - hasBorderRadius = true; - } - - return ( - - {children} - - ); -}; diff --git a/polaris-react/src/components/AlphaCard/index.ts b/polaris-react/src/components/AlphaCard/index.ts deleted file mode 100644 index 48ec946eecf..00000000000 --- a/polaris-react/src/components/AlphaCard/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './AlphaCard'; diff --git a/polaris-react/src/components/AlphaCard/tests/AlphaCard.test.tsx b/polaris-react/src/components/AlphaCard/tests/AlphaCard.test.tsx deleted file mode 100644 index 8048d406b26..00000000000 --- a/polaris-react/src/components/AlphaCard/tests/AlphaCard.test.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import React from 'react'; -import {mountWithApp} from 'tests/utilities'; -import {matchMedia} from '@shopify/jest-dom-mocks'; -import {setMediaWidth} from 'tests/utilities/breakpoints'; - -import {AlphaCard} from '..'; - -const heading =

Online store dashboard

; -const subheading =

View a summary of your online store performance

; - -describe('AlphaCard', () => { - beforeEach(() => { - matchMedia.mock(); - }); - - afterEach(() => { - matchMedia.restore(); - }); - - it('renders children', () => { - const alphaCard = mountWithApp( - - {heading} - {subheading} - , - ); - - expect(alphaCard).toContainReactComponentTimes('p', 2); - }); - - it('sets default border radius when roundedAbove breakpoint passed in', () => { - setMediaWidth('breakpoints-sm'); - const alphaCard = mountWithApp( - - {heading} - {subheading} - , - ); - - expect(alphaCard).toContainReactComponent('div', { - style: expect.objectContaining({ - '--pc-box-border-radius': 'var(--p-border-radius-2)', - }), - }); - }); -}); diff --git a/polaris-react/src/components/AlphaStack/AlphaStack.scss b/polaris-react/src/components/AlphaStack/AlphaStack.scss deleted file mode 100644 index 1f2dbe2bf1e..00000000000 --- a/polaris-react/src/components/AlphaStack/AlphaStack.scss +++ /dev/null @@ -1,54 +0,0 @@ -@import '../../styles/common'; - -.AlphaStack { - // stylelint-disable -- Polaris component custom properties - --pc-stack-align: initial; - --pc-stack-gap-xs: 0; - --pc-stack-gap-sm: var(--pc-stack-gap-xs); - --pc-stack-gap-md: var(--pc-stack-gap-sm); - --pc-stack-gap-lg: var(--pc-stack-gap-md); - --pc-stack-gap-xl: var(--pc-stack-gap-lg); - // stylelint-enable - - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - display: flex; - // stylelint-disable-next-line -- local component custom property is required for flex direction - flex-direction: var(--pc-stack-order); - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - align-items: var(--pc-stack-align); - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - gap: var(--pc-stack-gap-xs); - - @media #{$p-breakpoints-sm-up} { - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - gap: var(--pc-stack-gap-sm); - } - - @media #{$p-breakpoints-md-up} { - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - gap: var(--pc-stack-gap-md); - } - - @media #{$p-breakpoints-lg-up} { - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - gap: var(--pc-stack-gap-lg); - } - - @media #{$p-breakpoints-xl-up} { - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - gap: var(--pc-stack-gap-xl); - } -} - -.listReset { - list-style-type: none; - margin-block-start: 0; - margin-block-end: 0; - padding-inline-start: 0; -} - -.fieldsetReset { - border: none; - margin: 0; - padding: 0; -} diff --git a/polaris-react/src/components/AlphaStack/AlphaStack.stories.tsx b/polaris-react/src/components/AlphaStack/AlphaStack.stories.tsx deleted file mode 100644 index 9fed96ad2df..00000000000 --- a/polaris-react/src/components/AlphaStack/AlphaStack.stories.tsx +++ /dev/null @@ -1,103 +0,0 @@ -import React from 'react'; -import type {ComponentMeta} from '@storybook/react'; -import {Box, AlphaStack} from '@shopify/polaris'; - -export default { - component: AlphaStack, -} as ComponentMeta; - -export function Default() { - return ( - - - 01 - - - 02 - - - 03 - - - ); -} - -export function WithGap() { - return ( - - - 01 - - - 02 - - - 03 - - - ); -} - -export function WithResponsiveGap() { - return ( - - - 01 - - - 02 - - - 03 - - - ); -} - -export function WithAlignStart() { - return ( - - - 01 - - - 02 - - - 03 - - - ); -} - -export function WithAlignCenter() { - return ( - - - 01 - - - 02 - - - 03 - - - ); -} - -export function WithAlignEnd() { - return ( - - - 01 - - - 02 - - - 03 - - - ); -} diff --git a/polaris-react/src/components/AlphaStack/AlphaStack.tsx b/polaris-react/src/components/AlphaStack/AlphaStack.tsx deleted file mode 100644 index 5d542d0b56c..00000000000 --- a/polaris-react/src/components/AlphaStack/AlphaStack.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import React, {createElement} from 'react'; -import type {SpacingSpaceScale} from '@shopify/polaris-tokens'; - -import { - classNames, - sanitizeCustomProperties, - getResponsiveProps, -} from '../../utilities/css'; -import type {ResponsiveProp} from '../../utilities/css'; - -import styles from './AlphaStack.scss'; - -type Align = 'start' | 'end' | 'center'; - -type Element = 'div' | 'ul' | 'ol' | 'fieldset'; - -type Gap = ResponsiveProp; - -export interface AlphaStackProps extends React.AriaAttributes { - children?: React.ReactNode; - /** HTML Element type - * @default 'div' - */ - as?: Element; - /** Horizontal alignment of children */ - align?: Align; - /** The spacing between children */ - gap?: Gap; - /** HTML id attribute */ - id?: string; - /** Reverse the render order of child items - * @default false - */ - reverseOrder?: boolean; -} - -export const AlphaStack = ({ - as = 'div', - children, - align, - gap, - id, - reverseOrder = false, - ...restProps -}: AlphaStackProps) => { - const className = classNames( - styles.AlphaStack, - (as === 'ul' || as === 'ol') && styles.listReset, - as === 'fieldset' && styles.fieldsetReset, - ); - - const style = { - '--pc-stack-align': align ? `${align}` : '', - '--pc-stack-order': reverseOrder ? 'column-reverse' : 'column', - ...getResponsiveProps('stack', 'gap', 'space', gap), - } as React.CSSProperties; - - return createElement( - as, - { - className, - style: sanitizeCustomProperties(style), - ...restProps, - }, - children, - ); -}; diff --git a/polaris-react/src/components/AlphaStack/index.ts b/polaris-react/src/components/AlphaStack/index.ts deleted file mode 100644 index 832515641aa..00000000000 --- a/polaris-react/src/components/AlphaStack/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './AlphaStack'; diff --git a/polaris-react/src/components/AlphaStack/tests/AlphaStack.test.tsx b/polaris-react/src/components/AlphaStack/tests/AlphaStack.test.tsx deleted file mode 100644 index 8b55eaa455a..00000000000 --- a/polaris-react/src/components/AlphaStack/tests/AlphaStack.test.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import React from 'react'; -import {mountWithApp} from 'tests/utilities'; - -import {AlphaStack} from '../AlphaStack'; - -const text = 'This is a stack'; -const children =

{text}

; - -describe('', () => { - it('renders children', () => { - const stack = mountWithApp({children}); - - expect(stack).toContainReactComponent('p', {children: text}); - }); - - it('renders custom properties by default', () => { - const stack = mountWithApp({children}); - - expect(stack).toContainReactComponent('div', { - style: expect.objectContaining({ - '--pc-stack-order': 'column', - }) as React.CSSProperties, - }); - }); - - it('overrides custom properties if they are passed in', () => { - const stack = mountWithApp( - - {children} - , - ); - - expect(stack).toContainReactComponent('div', { - style: expect.objectContaining({ - '--pc-stack-align': 'center', - '--pc-stack-gap-xs': 'var(--p-space-10)', - }) as React.CSSProperties, - }); - }); - - it('accepts gap based on breakpoints', () => { - const stack = mountWithApp( - {children}, - ); - - expect(stack).toContainReactComponent('div', { - style: expect.objectContaining({ - '--pc-stack-gap-md': 'var(--p-space-8)', - '--pc-stack-gap-xs': 'var(--p-space-2)', - }) as React.CSSProperties, - }); - }); -}); diff --git a/polaris-react/src/components/AppProvider/AppProvider.scss b/polaris-react/src/components/AppProvider/AppProvider.scss index 7f385c5448b..a14a87326be 100644 --- a/polaris-react/src/components/AppProvider/AppProvider.scss +++ b/polaris-react/src/components/AppProvider/AppProvider.scss @@ -10,9 +10,6 @@ body { font-size: var(--p-font-size-100); line-height: var(--p-font-line-height-2); font-weight: var(--p-font-weight-regular); - - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - text-transform: initial; letter-spacing: initial; // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY diff --git a/polaris-react/src/components/AppProvider/AppProvider.stories.tsx b/polaris-react/src/components/AppProvider/AppProvider.stories.tsx index 37ac23731ad..635ca6ac838 100644 --- a/polaris-react/src/components/AppProvider/AppProvider.stories.tsx +++ b/polaris-react/src/components/AppProvider/AppProvider.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useState} from 'react'; +import { useCallback, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import { AppProvider, @@ -154,7 +154,7 @@ export function WithLinkComponent() { return ( diff --git a/polaris-react/src/components/AppProvider/AppProvider.tsx b/polaris-react/src/components/AppProvider/AppProvider.tsx index 42f88cd4f3a..b6e7ab99099 100644 --- a/polaris-react/src/components/AppProvider/AppProvider.tsx +++ b/polaris-react/src/components/AppProvider/AppProvider.tsx @@ -1,4 +1,4 @@ -import React, {Component} from 'react'; +import {Component} from 'react'; import {EphemeralPresenceManager} from '../EphemeralPresenceManager'; import {MediaQueryProvider} from '../MediaQueryProvider'; @@ -15,11 +15,6 @@ import { } from '../../utilities/sticky-manager'; import {LinkContext, LinkLikeComponent} from '../../utilities/link'; import {FeaturesConfig, FeaturesContext} from '../../utilities/features'; -import { - UniqueIdFactory, - UniqueIdFactoryContext, - globalIdGeneratorFactory, -} from '../../utilities/unique-id'; import './AppProvider.scss'; import './global.scss'; @@ -43,13 +38,11 @@ export interface AppProviderProps { export class AppProvider extends Component { private stickyManager: StickyManager; private scrollLockManager: ScrollLockManager; - private uniqueIdFactory: UniqueIdFactory; constructor(props: AppProviderProps) { super(props); this.stickyManager = new StickyManager(); this.scrollLockManager = new ScrollLockManager(); - this.uniqueIdFactory = new UniqueIdFactory(globalIdGeneratorFactory); const {i18n, linkComponent} = this.props; @@ -98,19 +91,17 @@ export class AppProvider extends Component { - - - - - - - {children} - - - - - - + + + + + + {children} + + + + + diff --git a/polaris-react/src/components/AppProvider/tests/AppProvider.test.tsx b/polaris-react/src/components/AppProvider/tests/AppProvider.test.tsx index 015400b696c..6910c2735dd 100644 --- a/polaris-react/src/components/AppProvider/tests/AppProvider.test.tsx +++ b/polaris-react/src/components/AppProvider/tests/AppProvider.test.tsx @@ -1,4 +1,4 @@ -import React, {useContext} from 'react'; +import {useContext} from 'react'; import {matchMedia} from '@shopify/jest-dom-mocks'; import {mountWithApp} from 'tests/utilities'; diff --git a/polaris-react/src/components/Autocomplete/Autocomplete.stories.tsx b/polaris-react/src/components/Autocomplete/Autocomplete.stories.tsx index a51fc0ab604..c03f7b6cc20 100644 --- a/polaris-react/src/components/Autocomplete/Autocomplete.stories.tsx +++ b/polaris-react/src/components/Autocomplete/Autocomplete.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useMemo, useState} from 'react'; +import { useCallback, useMemo, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import { Autocomplete, diff --git a/polaris-react/src/components/Autocomplete/Autocomplete.tsx b/polaris-react/src/components/Autocomplete/Autocomplete.tsx index a28e05ac408..cad94b9e2df 100644 --- a/polaris-react/src/components/Autocomplete/Autocomplete.tsx +++ b/polaris-react/src/components/Autocomplete/Autocomplete.tsx @@ -1,4 +1,4 @@ -import React, {useMemo, useCallback} from 'react'; +import {useMemo, useCallback} from 'react'; import type { ActionListItemDescriptor, diff --git a/polaris-react/src/components/Autocomplete/components/MappedAction/MappedAction.tsx b/polaris-react/src/components/Autocomplete/components/MappedAction/MappedAction.tsx index 34fdbe6f5c7..98bdb533450 100644 --- a/polaris-react/src/components/Autocomplete/components/MappedAction/MappedAction.tsx +++ b/polaris-react/src/components/Autocomplete/components/MappedAction/MappedAction.tsx @@ -1,4 +1,4 @@ -import React, {useMemo} from 'react'; +import {useMemo} from 'react'; import type {ActionListItemDescriptor} from '../../../../types'; import {Badge} from '../../../Badge'; diff --git a/polaris-react/src/components/Autocomplete/components/MappedAction/tests/MappedAction.test.tsx b/polaris-react/src/components/Autocomplete/components/MappedAction/tests/MappedAction.test.tsx index a279e646688..cd6161aed1a 100644 --- a/polaris-react/src/components/Autocomplete/components/MappedAction/tests/MappedAction.test.tsx +++ b/polaris-react/src/components/Autocomplete/components/MappedAction/tests/MappedAction.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithListboxProvider} from 'tests/utilities/listbox'; import {Listbox} from '../../../../Listbox'; diff --git a/polaris-react/src/components/Autocomplete/components/MappedOption/MappedOption.tsx b/polaris-react/src/components/Autocomplete/components/MappedOption/MappedOption.tsx index be95bdd3b47..55a611a4359 100644 --- a/polaris-react/src/components/Autocomplete/components/MappedOption/MappedOption.tsx +++ b/polaris-react/src/components/Autocomplete/components/MappedOption/MappedOption.tsx @@ -1,4 +1,4 @@ -import React, {memo} from 'react'; +import { memo } from 'react'; import type {OptionDescriptor, ArrayElement} from '../../../../types'; import {Listbox} from '../../../Listbox'; diff --git a/polaris-react/src/components/Autocomplete/components/MappedOption/tests/MappedOption.test.tsx b/polaris-react/src/components/Autocomplete/components/MappedOption/tests/MappedOption.test.tsx index 3b7a1ca8373..1864d7835bc 100644 --- a/polaris-react/src/components/Autocomplete/components/MappedOption/tests/MappedOption.test.tsx +++ b/polaris-react/src/components/Autocomplete/components/MappedOption/tests/MappedOption.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithListboxProvider} from 'tests/utilities/listbox'; import {Listbox} from '../../../../Listbox'; diff --git a/polaris-react/src/components/Autocomplete/tests/Autocomplete.test.tsx b/polaris-react/src/components/Autocomplete/tests/Autocomplete.test.tsx index e80c2f8323c..d406ce2269b 100644 --- a/polaris-react/src/components/Autocomplete/tests/Autocomplete.test.tsx +++ b/polaris-react/src/components/Autocomplete/tests/Autocomplete.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp, ReactTestingElement, CustomRoot} from 'tests/utilities'; import {TextField} from '../../TextField'; diff --git a/polaris-react/src/components/Avatar/Avatar.stories.tsx b/polaris-react/src/components/Avatar/Avatar.stories.tsx index cbc0d7dc052..ae1cffcea30 100644 --- a/polaris-react/src/components/Avatar/Avatar.stories.tsx +++ b/polaris-react/src/components/Avatar/Avatar.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useState} from 'react'; +import { useCallback, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import { ActionList, diff --git a/polaris-react/src/components/Avatar/Avatar.tsx b/polaris-react/src/components/Avatar/Avatar.tsx index 535d8fa65cd..2fb1640cb01 100644 --- a/polaris-react/src/components/Avatar/Avatar.tsx +++ b/polaris-react/src/components/Avatar/Avatar.tsx @@ -1,4 +1,4 @@ -import React, {useState, useCallback, useEffect} from 'react'; +import { useState, useCallback, useEffect } from 'react'; import {classNames, variationName} from '../../utilities/css'; import {useI18n} from '../../utilities/i18n'; diff --git a/polaris-react/src/components/Avatar/tests/Avatar-ssr.test.tsx b/polaris-react/src/components/Avatar/tests/Avatar-ssr.test.tsx index 08404ff39de..98cd551f2f5 100644 --- a/polaris-react/src/components/Avatar/tests/Avatar-ssr.test.tsx +++ b/polaris-react/src/components/Avatar/tests/Avatar-ssr.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Image} from '../../Image'; diff --git a/polaris-react/src/components/Avatar/tests/Avatar.test.tsx b/polaris-react/src/components/Avatar/tests/Avatar.test.tsx index 1487bf253c5..a7a9b09c6a7 100644 --- a/polaris-react/src/components/Avatar/tests/Avatar.test.tsx +++ b/polaris-react/src/components/Avatar/tests/Avatar.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Image} from '../../Image'; diff --git a/polaris-react/src/components/Backdrop/Backdrop.tsx b/polaris-react/src/components/Backdrop/Backdrop.tsx index 10c2539ca97..e6eef7a2542 100644 --- a/polaris-react/src/components/Backdrop/Backdrop.tsx +++ b/polaris-react/src/components/Backdrop/Backdrop.tsx @@ -1,4 +1,4 @@ -import React, {Dispatch, SetStateAction} from 'react'; +import { Dispatch, SetStateAction } from 'react'; import {classNames} from '../../utilities/css'; import {ScrollLock} from '../ScrollLock'; diff --git a/polaris-react/src/components/Backdrop/tests/Backdrop.test.tsx b/polaris-react/src/components/Backdrop/tests/Backdrop.test.tsx index 1ef6edb749f..70a81b6e5ba 100644 --- a/polaris-react/src/components/Backdrop/tests/Backdrop.test.tsx +++ b/polaris-react/src/components/Backdrop/tests/Backdrop.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Backdrop} from '..'; diff --git a/polaris-react/src/components/Badge/Badge.stories.tsx b/polaris-react/src/components/Badge/Badge.stories.tsx index 76c86d77eb0..cf47eae035c 100644 --- a/polaris-react/src/components/Badge/Badge.stories.tsx +++ b/polaris-react/src/components/Badge/Badge.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import {Badge} from '@shopify/polaris'; diff --git a/polaris-react/src/components/Badge/Badge.tsx b/polaris-react/src/components/Badge/Badge.tsx index 1fb8ae0112c..d0db82da20c 100644 --- a/polaris-react/src/components/Badge/Badge.tsx +++ b/polaris-react/src/components/Badge/Badge.tsx @@ -1,4 +1,4 @@ -import React, {useContext} from 'react'; +import { useContext } from 'react'; import {classNames, variationName} from '../../utilities/css'; import {useI18n} from '../../utilities/i18n'; diff --git a/polaris-react/src/components/Badge/components/Pip/Pip.tsx b/polaris-react/src/components/Badge/components/Pip/Pip.tsx index 3faa53632fd..5b161390034 100644 --- a/polaris-react/src/components/Badge/components/Pip/Pip.tsx +++ b/polaris-react/src/components/Badge/components/Pip/Pip.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {classNames, variationName} from '../../../../utilities/css'; import type {Progress, Status} from '../../types'; import {Text} from '../../../Text'; diff --git a/polaris-react/src/components/Badge/tests/Badge.test.tsx b/polaris-react/src/components/Badge/tests/Badge.test.tsx index fdd52dcc868..d0b2f7a0cf7 100644 --- a/polaris-react/src/components/Badge/tests/Badge.test.tsx +++ b/polaris-react/src/components/Badge/tests/Badge.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {GlobeMinor} from '@shopify/polaris-icons'; diff --git a/polaris-react/src/components/Banner/Banner.scss b/polaris-react/src/components/Banner/Banner.scss index b85f2b309f7..a5fd3b56153 100644 --- a/polaris-react/src/components/Banner/Banner.scss +++ b/polaris-react/src/components/Banner/Banner.scss @@ -253,8 +253,6 @@ font-size: var(--p-font-size-100); font-weight: var(--p-font-weight-medium); line-height: var(--p-font-line-height-1); - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - text-transform: initial; letter-spacing: initial; color: var(--p-text); diff --git a/polaris-react/src/components/Banner/Banner.stories.tsx b/polaris-react/src/components/Banner/Banner.stories.tsx index bfefc6826f1..a444eada99b 100644 --- a/polaris-react/src/components/Banner/Banner.stories.tsx +++ b/polaris-react/src/components/Banner/Banner.stories.tsx @@ -1,7 +1,7 @@ -import React, {useCallback, useEffect, useRef, useState} from 'react'; +import { useCallback, useEffect, useRef, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import { - AlphaStack, + Stack, Banner, Button, LegacyCard, @@ -193,7 +193,7 @@ export function InACard() { export function WithEndJustifiedContent() { return ( - + Deployment failed in 5min @@ -203,7 +203,7 @@ export function WithEndJustifiedContent() {

This order was archived on March 7, 2017 at 3:12pm EDT.

-
+
); } diff --git a/polaris-react/src/components/Banner/Banner.tsx b/polaris-react/src/components/Banner/Banner.tsx index af73e6b690a..ecec4ba8ef7 100644 --- a/polaris-react/src/components/Banner/Banner.tsx +++ b/polaris-react/src/components/Banner/Banner.tsx @@ -1,4 +1,4 @@ -import React, { +import { forwardRef, useRef, useState, diff --git a/polaris-react/src/components/Banner/tests/Banner.test.tsx b/polaris-react/src/components/Banner/tests/Banner.test.tsx index a9fcc3708dc..70b5168ef13 100644 --- a/polaris-react/src/components/Banner/tests/Banner.test.tsx +++ b/polaris-react/src/components/Banner/tests/Banner.test.tsx @@ -1,4 +1,4 @@ -import React, {useEffect, useRef} from 'react'; +import {useEffect, useRef} from 'react'; import { CirclePlusMinor, CircleTickMajor, diff --git a/polaris-react/src/components/Bleed/Bleed.stories.tsx b/polaris-react/src/components/Bleed/Bleed.stories.tsx index aa9e445a69f..278a2009c6c 100644 --- a/polaris-react/src/components/Bleed/Bleed.stories.tsx +++ b/polaris-react/src/components/Bleed/Bleed.stories.tsx @@ -1,13 +1,5 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; -import { - AlphaCard, - Bleed, - Box, - Divider, - LegacyStack, - Text, -} from '@shopify/polaris'; +import {Card, Bleed, Box, Divider, LegacyStack, Text} from '@shopify/polaris'; export default { component: Bleed, @@ -22,7 +14,7 @@ const styles = { export function Default() { return ( - + Section 01 @@ -36,7 +28,7 @@ export function Default() { Section 02 - + ); } diff --git a/polaris-react/src/components/Bleed/Bleed.tsx b/polaris-react/src/components/Bleed/Bleed.tsx index 97928ae449a..9705bd4b4ea 100644 --- a/polaris-react/src/components/Bleed/Bleed.tsx +++ b/polaris-react/src/components/Bleed/Bleed.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {SpacingSpaceScale} from '@shopify/polaris-tokens'; import { diff --git a/polaris-react/src/components/Bleed/tests/Bleed.test.tsx b/polaris-react/src/components/Bleed/tests/Bleed.test.tsx index 78eb350cc6d..3a3acffa84b 100644 --- a/polaris-react/src/components/Bleed/tests/Bleed.test.tsx +++ b/polaris-react/src/components/Bleed/tests/Bleed.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Bleed} from '../Bleed'; diff --git a/polaris-react/src/components/Box/Box.stories.tsx b/polaris-react/src/components/Box/Box.stories.tsx index 62db7d10a78..baab180d74e 100644 --- a/polaris-react/src/components/Box/Box.stories.tsx +++ b/polaris-react/src/components/Box/Box.stories.tsx @@ -1,6 +1,5 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; -import {AlphaStack, Box, Icon} from '@shopify/polaris'; +import {Stack, Box, Icon} from '@shopify/polaris'; import {PaintBrushMajor} from '@shopify/polaris-icons'; export default { @@ -33,7 +32,7 @@ export function WithBorderRadius() { export function WithResponsivePadding() { return ( - + @@ -68,6 +67,6 @@ export function WithResponsivePadding() { > - + ); } diff --git a/polaris-react/src/components/Box/Box.tsx b/polaris-react/src/components/Box/Box.tsx index 50f8d039b83..7980208e7b3 100644 --- a/polaris-react/src/components/Box/Box.tsx +++ b/polaris-react/src/components/Box/Box.tsx @@ -1,4 +1,4 @@ -import React, {createElement, forwardRef} from 'react'; +import {createElement, forwardRef} from 'react'; import type { ColorsActionTokenAlias, ColorsBackdropTokenAlias, diff --git a/polaris-react/src/components/Box/tests/Box.test.tsx b/polaris-react/src/components/Box/tests/Box.test.tsx index 4d6b90efea9..3d57ef90827 100644 --- a/polaris-react/src/components/Box/tests/Box.test.tsx +++ b/polaris-react/src/components/Box/tests/Box.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import type {ColorsTokenName, ShapeTokenName} from '@shopify/polaris-tokens'; diff --git a/polaris-react/src/components/Breadcrumbs/Breadcrumbs.tsx b/polaris-react/src/components/Breadcrumbs/Breadcrumbs.tsx index 8c11f72bb8e..fceb3afc3fc 100644 --- a/polaris-react/src/components/Breadcrumbs/Breadcrumbs.tsx +++ b/polaris-react/src/components/Breadcrumbs/Breadcrumbs.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {ArrowLeftMinor} from '@shopify/polaris-icons'; import {Icon} from '../Icon'; @@ -10,29 +9,12 @@ import {Text} from '../Text'; import styles from './Breadcrumbs.scss'; export interface BreadcrumbsProps { - /** @deprecated Collection of breadcrumbs */ - breadcrumbs?: (CallbackAction | LinkAction) | (CallbackAction | LinkAction)[]; /** Back action link */ - backAction?: CallbackAction | LinkAction; + backAction: CallbackAction | LinkAction; } -export function Breadcrumbs({breadcrumbs, backAction}: BreadcrumbsProps) { - const breadcrumb = - backAction ?? - (Array.isArray(breadcrumbs) - ? breadcrumbs[breadcrumbs.length - 1] - : breadcrumbs); - if (breadcrumb == null) { - if (process.env.NODE_ENV === 'development') { - // eslint-disable-next-line no-console - console.warn( - 'Please provide a value to backAction, it will become required in the next major release.', - ); - } - return null; - } - - const {content} = breadcrumb; +export function Breadcrumbs({backAction}: BreadcrumbsProps) { + const {content} = backAction; const contentMarkup = ( <> @@ -46,13 +28,13 @@ export function Breadcrumbs({breadcrumbs, backAction}: BreadcrumbsProps) { ); const breadcrumbMarkup = - 'url' in breadcrumb ? ( + 'url' in backAction ? ( {contentMarkup} @@ -60,10 +42,10 @@ export function Breadcrumbs({breadcrumbs, backAction}: BreadcrumbsProps) { diff --git a/polaris-react/src/components/Breadcrumbs/tests/Breadcrumbs.test.tsx b/polaris-react/src/components/Breadcrumbs/tests/Breadcrumbs.test.tsx index e5033a7cc8a..c593cc03bf3 100644 --- a/polaris-react/src/components/Breadcrumbs/tests/Breadcrumbs.test.tsx +++ b/polaris-react/src/components/Breadcrumbs/tests/Breadcrumbs.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import type {CallbackAction, LinkAction} from '../../../types'; @@ -8,31 +7,25 @@ import {Text} from '../../Text'; describe('', () => { describe('url', () => { it('uses tags when passed a LinkAction', () => { - const linkBreadcrumbs: LinkAction[] = [ - { - content: 'Products', - url: 'https://www.shopify.com', - }, - ]; - + const linkBackAction: LinkAction = { + content: 'Products', + url: 'https://www.shopify.com', + }; const breadcrumbs = mountWithApp( - , + , ); expect(breadcrumbs).toContainReactComponentTimes('a', 1); }); it('passes the accessibilityLabel through to tag', () => { - const linkBreadcrumbs: LinkAction[] = [ - { - content: 'Products', - url: 'https://shopify.com', - accessibilityLabel: 'Go to Products', - }, - ]; - + const linkBackAction: LinkAction = { + content: 'Products', + url: 'https://shopify.com', + accessibilityLabel: 'Go to Products', + }; const breadcrumbs = mountWithApp( - , + , ); expect(breadcrumbs).toContainReactComponent('a', { @@ -43,31 +36,25 @@ describe('', () => { describe('onAction()', () => { it('uses - - - - - - - ); -} - -export function WithDestructiveFooterAction() { - return ( - - - - 1 × Oasis Glass, 4-Pack - 1 × Anubis Cup, 2-Pack - - - - ); -} - -export function WithMultipleSections() { - return ( - - + + + + Online store dashboard +

View a summary of your online store’s performance.

-
- - -

- View a summary of your online store’s performance, including sales, - visitors, top products, and referrals. -

-
+
); } -export function WithMultipleTitledSections() { +export function WithBackgroundSubdued() { return ( - - + + + + Online store dashboard +

View a summary of your online store’s performance.

-
- - -

- View a summary of your online store’s performance, including sales, - visitors, top products, and referrals. -

-
-
- ); -} - -export function WithSectionsAndActions() { - return ( - - -

John Smith

-
- -

john.smith@example.com

-
-
- ); -} - -export function WithSubsection() { - return ( - - -

John Smith

-
- - - 123 First St -
- Somewhere -
- The Universe -
- - 123 Second St -
- Somewhere -
- The Universe -
-
- - - A single subsection without a sibling has no visual appearance - - +
); } -export function WithDestructiveAction() { +export function WithBorderRadiusRoundedAbove() { return ( - - -

John Smith

-
- -

john.smith@example.com

-
-
- ); -} - -export function WithASubduedSection() { - return ( - - - - Felix Crafford - Ezequiel Manno - - - - - - Felix Crafford - Ezequiel Manno - - - - ); -} - -export function WithSubduedForSecondaryContent() { - return ( - - - Felix Crafford - Ezequiel Manno - + + + + Online store dashboard + +

View a summary of your online store’s performance.

+
); } -export function WithSeparateHeader() { +export function WithResponsivePadding() { return ( - - - - Add account - - } - onClose={() => {}} + + + + Online store dashboard + +

View a summary of your online store’s performance.

+
+
+ ); +} + +export function WithSubduedSection() { + return ( + + + + Staff accounts + + + + Felix Crafford + Ezequiel Manno + + + + + + - -
-
- - - Felix Crafford - Ezequiel Manno - - -
- ); -} - -export function WithCustomReactNodeTitle() { - return ( - - - + - New Products + Deactivated staff accounts - - } - > - - Socks - Super Shoes - - - - ); -} - -export function WithAllElements() { - return ( - - - - View Sales - - } - onClose={() => {}} - > - - - - - - You can use sales reports to see information about your customers’ - orders based on criteria such as sales over time, by channel, or by - staff. - - - - { - const {sales, amount, url} = item; - return ( - - - {sales} - {amount} - - - ); - }} - /> - - - - Payouts - Total Sales By Channel - - - - - The sales reports are available only if your store is on the Shopify - plan or higher. - - - - ); -} - -export function WithFlushedSections() { - return ( - - - a sheet with purple and orange stripes - - - - You can use sales reports to see information about your customers’ - orders based on criteria such as sales over time, by channel, or by - staff. - - + + Felix Crafford + Ezequiel Manno + + + + ); } diff --git a/polaris-react/src/components/Card/Card.tsx b/polaris-react/src/components/Card/Card.tsx index 70d7eac86b6..dac1d57b265 100644 --- a/polaris-react/src/components/Card/Card.tsx +++ b/polaris-react/src/components/Card/Card.tsx @@ -1,160 +1,61 @@ -import React from 'react'; +import type { + BreakpointsAlias, + ColorsTokenName, + ShapeBorderRadiusScale, + SpacingSpaceScale, +} from '@shopify/polaris-tokens'; -import {useI18n} from '../../utilities/i18n'; -import {classNames} from '../../utilities/css'; -import {useToggle} from '../../utilities/use-toggle'; -import {WithinContentContext} from '../../utilities/within-content-context'; -import {ButtonGroup} from '../ButtonGroup'; -import type {DisableableAction, ComplexAction} from '../../types'; -import {ActionList} from '../ActionList'; -import {Button, buttonFrom} from '../Button'; -import {Popover} from '../Popover'; +import {useBreakpoints} from '../../utilities/breakpoints'; +import type {ResponsiveProp} from '../../utilities/css'; +import {Box} from '../Box'; -// eslint-disable-next-line import/no-deprecated -import {Header, Section, Subsection} from './components'; -import styles from './Card.scss'; +type CardBackgroundColorTokenScale = Extract< + ColorsTokenName, + 'surface' | 'surface-subdued' +>; -export type { - CardSectionProps, - CardHeaderProps, - CardSubsectionProps, -} from './components'; +type Spacing = ResponsiveProp; export interface CardProps { - /** Title content for the card */ - title?: React.ReactNode; - /** Inner content of the card */ children?: React.ReactNode; - /** A less prominent card */ - subdued?: boolean; - /** Auto wrap content in section */ - sectioned?: boolean; - /** Card header actions */ - actions?: DisableableAction[]; - /** Primary action in the card footer */ - primaryFooterAction?: ComplexAction; - /** Secondary actions in the card footer */ - secondaryFooterActions?: ComplexAction[]; - /** The content of the disclosure button rendered when there is more than one secondary footer action */ - secondaryFooterActionsDisclosureText?: string; - /** Alignment of the footer actions on the card, defaults to right */ - footerActionAlignment?: 'right' | 'left'; - /** Allow the card to be hidden when printing */ - hideOnPrint?: boolean; + /** Background color + * @default 'surface' + */ + background?: CardBackgroundColorTokenScale; + /** The spacing around the card + * @default {xs: '4', sm: '5'} + * @example + * padding='4' + * padding={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}} + */ + padding?: Spacing; + /** Border radius value above a set breakpoint */ + roundedAbove?: BreakpointsAlias; } -// TypeScript can't generate types that correctly infer the typing of -// subcomponents so explicitly state the subcomponents in the type definition. -// Letting this be implicit works in this project but fails in projects that use -// generated *.d.ts files. -/** @deprecated Use AlphaCard instead. */ -export const Card: React.FunctionComponent & { - // eslint-disable-next-line import/no-deprecated - Header: typeof Header; - // eslint-disable-next-line import/no-deprecated - Section: typeof Section; - // eslint-disable-next-line import/no-deprecated - Subsection: typeof Subsection; -} = function Card({ +export const Card = ({ children, - hideOnPrint, - title, - subdued, - sectioned, - actions, - primaryFooterAction, - secondaryFooterActions, - secondaryFooterActionsDisclosureText, - footerActionAlignment = 'right', -}: CardProps) { - if (process.env.NODE_ENV === 'development') { - // eslint-disable-next-line no-console - console.warn( - 'Deprecation: is deprecated. This component will be removed in a future major version of Polaris. Use or instead.', - ); - } - - const i18n = useI18n(); - const { - value: secondaryActionsPopoverOpen, - toggle: toggleSecondaryActionsPopoverOpen, - } = useToggle(false); - - const className = classNames( - styles.Card, - subdued && styles.subdued, - hideOnPrint && styles.hideOnPrint, - ); + background = 'surface', + padding = {xs: '4', sm: '5'}, + roundedAbove, +}: CardProps) => { + const breakpoints = useBreakpoints(); + const defaultBorderRadius = '2' as ShapeBorderRadiusScale; - const headerMarkup = - title || actions ?
: null; + let hasBorderRadius = !roundedAbove; - const content = sectioned ?
{children}
: children; - - const primaryFooterActionMarkup = primaryFooterAction - ? buttonFrom(primaryFooterAction, {primary: true}) - : null; - - let secondaryFooterActionsMarkup = null; - if (secondaryFooterActions && secondaryFooterActions.length) { - if (secondaryFooterActions.length === 1) { - secondaryFooterActionsMarkup = buttonFrom(secondaryFooterActions[0]); - } else { - secondaryFooterActionsMarkup = ( - <> - - {secondaryFooterActionsDisclosureText || - i18n.translate('Polaris.Common.more')} - - } - onClose={toggleSecondaryActionsPopoverOpen} - > - - - - ); - } + if (roundedAbove && breakpoints[`${roundedAbove}Up`]) { + hasBorderRadius = true; } - const footerMarkup = - primaryFooterActionMarkup || secondaryFooterActionsMarkup ? ( -
- {footerActionAlignment === 'right' ? ( - - {secondaryFooterActionsMarkup} - {primaryFooterActionMarkup} - - ) : ( - - {primaryFooterActionMarkup} - {secondaryFooterActionsMarkup} - - )} -
- ) : null; - return ( - -
- {headerMarkup} - {content} - {footerMarkup} -
-
+ + {children} + ); }; - -// eslint-disable-next-line import/no-deprecated -Card.Header = Header; -// eslint-disable-next-line import/no-deprecated -Card.Section = Section; -// eslint-disable-next-line import/no-deprecated -Card.Subsection = Subsection; diff --git a/polaris-react/src/components/Card/components/Header/Header.tsx b/polaris-react/src/components/Card/components/Header/Header.tsx deleted file mode 100644 index f1115fd9d2b..00000000000 --- a/polaris-react/src/components/Card/components/Header/Header.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import React, {isValidElement} from 'react'; - -import type {DisableableAction} from '../../../../types'; -import {buttonsFrom} from '../../../Button'; -import {ButtonGroup} from '../../../ButtonGroup'; -import {LegacyStack} from '../../../LegacyStack'; -import {Text} from '../../../Text'; -import styles from '../../Card.scss'; - -export interface CardHeaderProps { - title?: React.ReactNode; - actions?: DisableableAction[]; - children?: React.ReactNode; -} - -/** @deprecated Use LegacyCard or AlphaCard instead. */ -export function Header({children, title, actions}: CardHeaderProps) { - if (process.env.NODE_ENV === 'development') { - // eslint-disable-next-line no-console - console.warn( - 'Deprecation: is deprecated. This component will be removed in a future major version of Polaris. Use or instead.', - ); - } - - const actionMarkup = actions ? ( - {buttonsFrom(actions, {plain: true})} - ) : null; - - const titleMarkup = isValidElement(title) ? ( - title - ) : ( - - {title} - - ); - - const headingMarkup = - actionMarkup || children ? ( - - {titleMarkup} - {actionMarkup} - {children} - - ) : ( - titleMarkup - ); - - return
{headingMarkup}
; -} diff --git a/polaris-react/src/components/Card/components/Header/index.ts b/polaris-react/src/components/Card/components/Header/index.ts deleted file mode 100644 index 266dec8a1bc..00000000000 --- a/polaris-react/src/components/Card/components/Header/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Header'; diff --git a/polaris-react/src/components/Card/components/Header/tests/Header.test.tsx b/polaris-react/src/components/Card/components/Header/tests/Header.test.tsx deleted file mode 100644 index 374e49828b7..00000000000 --- a/polaris-react/src/components/Card/components/Header/tests/Header.test.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import React from 'react'; -import {mountWithApp} from 'tests/utilities'; - -import {buttonsFrom} from '../../../../Button'; -import {ButtonGroup} from '../../../../ButtonGroup'; -import {Text} from '../../../../Text'; -// eslint-disable-next-line import/no-deprecated -import {Header} from '../Header'; - -jest.mock('../../../../Button', () => ({ - ...(jest.requireActual('../../../../Button') as any), - buttonsFrom: jest.fn(), -})); - -const buttonsFromMock = buttonsFrom as jest.Mock; - -describe('
', () => { - describe('title', () => { - it('renders a heading when defined', () => { - const header = mountWithApp(
); - expect(header).toContainReactComponent(Text, {variant: 'headingMd'}); - }); - - it('renders the title directly if its a valid React element', () => { - const title =
Staff accounts
; - const header = mountWithApp(
); - expect(header).not.toContainReactComponent(Text, {variant: 'headingLg'}); - expect(header).toContainReactComponent('div', { - children: 'Staff accounts', - }); - }); - - it('is used as the content for the heading', () => { - const title = 'Staff accounts'; - const header = mountWithApp(
); - expect(header.find(Text, {variant: 'headingMd'})).toContainReactText( - title, - ); - }); - }); - - describe('actions', () => { - const mockActions = [{content: 'Preview'}]; - - it('renders a button group when defined', () => { - const header = mountWithApp(
); - expect(header).toContainReactComponent(ButtonGroup); - }); - - it('renders buttons for each action', () => { - mountWithApp(
); - expect(buttonsFromMock).toHaveBeenCalledWith( - mockActions, - expect.anything(), - ); - }); - - it('does not render a button group when not defined', () => { - const header = mountWithApp(
); - expect(header).not.toContainReactComponent(ButtonGroup); - }); - }); - - describe('children', () => { - it('renders when defined', () => { - const Children = () =>
Hello!
; - const header = mountWithApp( -
- -
, - ); - expect(header).toContainReactComponent(Children); - }); - }); -}); diff --git a/polaris-react/src/components/Card/components/Section/Section.tsx b/polaris-react/src/components/Card/components/Section/Section.tsx deleted file mode 100644 index 4c4d2bd2db4..00000000000 --- a/polaris-react/src/components/Card/components/Section/Section.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import React from 'react'; - -import {classNames} from '../../../../utilities/css'; -import type {ComplexAction} from '../../../../types'; -import {buttonsFrom} from '../../../Button'; -import {LegacyStack} from '../../../LegacyStack'; -import {ButtonGroup} from '../../../ButtonGroup'; -import {Text} from '../../../Text'; -import styles from '../../Card.scss'; - -export interface CardSectionProps { - title?: React.ReactNode; - children?: React.ReactNode; - subdued?: boolean; - flush?: boolean; - fullWidth?: boolean; - /** Allow the card to be hidden when printing */ - hideOnPrint?: boolean; - actions?: ComplexAction[]; -} - -/** @deprecated Use LegacyCard or AlphaCard instead. */ -export function Section({ - children, - title, - subdued, - flush, - fullWidth, - actions, - hideOnPrint, -}: CardSectionProps) { - if (process.env.NODE_ENV === 'development') { - // eslint-disable-next-line no-console - console.warn( - 'Deprecation: is deprecated. This component will be removed in a future major version of Polaris. Use or instead.', - ); - } - - const className = classNames( - styles.Section, - flush && styles['Section-flush'], - subdued && styles['Section-subdued'], - fullWidth && styles['Section-fullWidth'], - hideOnPrint && styles['Section-hideOnPrint'], - ); - - const actionMarkup = actions ? ( - {buttonsFrom(actions, {plain: true})} - ) : null; - - const titleMarkup = - typeof title === 'string' ? ( - - {title} - - ) : ( - title - ); - - const titleAreaMarkup = - titleMarkup || actionMarkup ? ( -
- {actionMarkup ? ( - - {titleMarkup} - {actionMarkup} - - ) : ( - titleMarkup - )} -
- ) : null; - - return ( -
- {titleAreaMarkup} - {children} -
- ); -} diff --git a/polaris-react/src/components/Card/components/Section/index.ts b/polaris-react/src/components/Card/components/Section/index.ts deleted file mode 100644 index b524e0f3c49..00000000000 --- a/polaris-react/src/components/Card/components/Section/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Section'; diff --git a/polaris-react/src/components/Card/components/Section/tests/Section.test.tsx b/polaris-react/src/components/Card/components/Section/tests/Section.test.tsx deleted file mode 100644 index cb5517f3afd..00000000000 --- a/polaris-react/src/components/Card/components/Section/tests/Section.test.tsx +++ /dev/null @@ -1,90 +0,0 @@ -import React from 'react'; -import {mountWithApp} from 'tests/utilities'; - -import {Badge} from '../../../../Badge'; -import {Button} from '../../../../Button'; -import {ButtonGroup} from '../../../../ButtonGroup'; -import {Text} from '../../../../Text'; -// eslint-disable-next-line import/no-deprecated -import {Section} from '../Section'; - -describe('', () => { - it('can have any valid react element as the card section title', () => { - const titleString = 'Online store'; - const badgeString = 'I am a badge'; - const titleMarkup = ( -

- {titleString} - {badgeString} -

- ); - - const section = mountWithApp(
); - const headerMarkup = section.find('h2')!; - - expect(headerMarkup).toContainReactText(titleString); - expect(headerMarkup.find(Badge)).toContainReactText(badgeString); - }); - - it('wraps plain string titles in a ', () => { - const titleString = 'Online store'; - const card = mountWithApp(
); - expect( - card.find(Text, {variant: 'headingSm', as: 'h3'}), - ).toContainReactText(titleString); - }); - - describe('hideWhenPrinting prop', () => { - it('renders classname "Section Section-hideOnPrint" when prop is passed', () => { - const card = mountWithApp(
); - - expect(card).toContainReactComponent('div', { - className: 'Section Section-hideOnPrint', - }); - }); - - it('does not render classname "Section Section-hideOnPrint" when prop is not passed', () => { - const card = mountWithApp(
); - - expect(card).not.toContainReactComponent('div', { - className: 'Section Section-hideOnPrint', - }); - }); - }); - - describe('actions', () => { - const mockActions = [{content: 'Preview'}, {content: 'Open'}]; - - it('renders a button group when defined', () => { - const section = mountWithApp(
); - expect(section).toContainReactComponent(ButtonGroup); - }); - - it('renders buttons for each action', () => { - const section = mountWithApp(
); - expect(section).toContainReactComponentTimes(Button, 2); - }); - - it('does not render a button group when not defined', () => { - const section = mountWithApp(
); - expect(section).not.toContainReactComponent(ButtonGroup); - }); - - it('renders both custom title markup and actions', () => { - const titleString = 'Online store'; - const badgeString = 'I am a badge'; - const titleMarkup = ( -

- {titleString} - {badgeString} -

- ); - const section = mountWithApp( -
, - ); - expect(section).toContainReactComponentTimes(Button, 2); - expect(section).toContainReactText(titleString); - expect(section.find(Badge)).toContainReactText(badgeString); - }); - }); -}); diff --git a/polaris-react/src/components/Card/components/Subsection/Subsection.tsx b/polaris-react/src/components/Card/components/Subsection/Subsection.tsx deleted file mode 100644 index f1715e61524..00000000000 --- a/polaris-react/src/components/Card/components/Subsection/Subsection.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import React from 'react'; - -import styles from '../../Card.scss'; - -export interface CardSubsectionProps { - children?: React.ReactNode; -} - -/** @deprecated Use LegacyCard or AlphaCard instead. */ -export function Subsection({children}: CardSubsectionProps) { - if (process.env.NODE_ENV === 'development') { - // eslint-disable-next-line no-console - console.warn( - 'Deprecation: is deprecated. This component will be removed in a future major version of Polaris. Use or instead.', - ); - } - - return
{children}
; -} diff --git a/polaris-react/src/components/Card/components/Subsection/index.ts b/polaris-react/src/components/Card/components/Subsection/index.ts deleted file mode 100644 index cddeba60629..00000000000 --- a/polaris-react/src/components/Card/components/Subsection/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Subsection'; diff --git a/polaris-react/src/components/Card/components/Subsection/tests/Subsection.test.tsx b/polaris-react/src/components/Card/components/Subsection/tests/Subsection.test.tsx deleted file mode 100644 index 353a2b9bdc9..00000000000 --- a/polaris-react/src/components/Card/components/Subsection/tests/Subsection.test.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from 'react'; -import {mountWithApp} from 'tests/utilities'; - -// eslint-disable-next-line import/no-deprecated -import {Subsection} from '../Subsection'; - -describe('', () => { - it('can have any valid react element for children', () => { - const childrenMarkup =

Some content

; - - const section = mountWithApp({childrenMarkup}); - - expect(section).toContainReactText('Some content'); - expect(section).toContainReactComponent('p'); - }); -}); diff --git a/polaris-react/src/components/Card/components/index.ts b/polaris-react/src/components/Card/components/index.ts deleted file mode 100644 index 194aac47a90..00000000000 --- a/polaris-react/src/components/Card/components/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './Header'; - -export * from './Section'; - -export * from './Subsection'; diff --git a/polaris-react/src/components/Card/tests/Card.test.tsx b/polaris-react/src/components/Card/tests/Card.test.tsx index 4c7cdc97f0d..22281e4f6a7 100644 --- a/polaris-react/src/components/Card/tests/Card.test.tsx +++ b/polaris-react/src/components/Card/tests/Card.test.tsx @@ -1,253 +1,45 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; +import {matchMedia} from '@shopify/jest-dom-mocks'; +import {setMediaWidth} from 'tests/utilities/breakpoints'; -import {Badge} from '../../Badge'; -import {Button} from '../../Button'; -import {Popover} from '../../Popover'; -import {ActionList} from '../../ActionList'; -import {WithinContentContext} from '../../../utilities/within-content-context'; -// eslint-disable-next-line import/no-deprecated -import {Card} from '../Card'; -// eslint-disable-next-line import/no-deprecated -import {Section} from '../components'; +import {Card} from '..'; -describe('', () => { - it('has a child with prop withinContentContainer set to true', () => { - function TestComponent(_: {withinContentContainer: any}) { - return null; - } +const heading =

Online store dashboard

; +const subheading =

View a summary of your online store performance

; - const component = mountWithApp( - - - {(withinContentContext) => { - return ( - - ); - }} - - , - ); - expect(component).toContainReactComponent(TestComponent, { - withinContentContainer: true, - }); +describe('Card', () => { + beforeEach(() => { + matchMedia.mock(); }); - it('has a header tag when the title is a string', () => { - const title = 'Online store'; - const card = mountWithApp(); - expect(card.find('h2')).toContainReactText(title); + afterEach(() => { + matchMedia.restore(); }); - it('can have any valid react element as the title', () => { - const titleString = 'Online store'; - const badgeString = 'I am a badge'; - const titleMarkup = ( -

- {titleString} - {badgeString} -

- ); - - const card = mountWithApp(); - const headerMarkup = card.find('h2')!; - - expect(headerMarkup).toContainReactText(titleString); - expect(headerMarkup.find(Badge)).toContainReactText(badgeString); - }); - - it('exposes the header component', () => { + it('renders children', () => { const card = mountWithApp( - - , - ); - // eslint-disable-next-line import/no-deprecated - expect(card).toContainReactComponent(Card.Header); - }); - - it('renders a
component with actions and no title', () => { - const card = mountWithApp( - -

Some card content.

+ {heading} + {subheading}
, ); - expect(card).toContainReactComponent(Button); - // eslint-disable-next-line import/no-deprecated - expect(card).toContainReactComponent(Card.Header); - }); - - describe('footerActionAlignment prop', () => { - it('renders right-aligned if not supplied', () => { - const card = mountWithApp( - -

Some card content.

-
, - ); - - const buttons = card.findAll(Button); - expect(buttons[0].prop('children')).toBe('secondary action'); - expect(buttons[1].prop('children')).toBe('primary action'); - }); - - it('renders right-aligned if set to "right"', () => { - const card = mountWithApp( - -

Some card content.

-
, - ); - - const buttons = card.findAll(Button); - expect(buttons[0].prop('children')).toBe('secondary action'); - expect(buttons[1].prop('children')).toBe('primary action'); - }); - - it('renders left-aligned if set to "left"', () => { - const card = mountWithApp( - -

Some card content.

-
, - ); - - const buttons = card.findAll(Button); - expect(buttons[0].prop('children')).toBe('primary action'); - expect(buttons[1].prop('children')).toBe('secondary action'); - }); - }); - - describe('hideWhenPrinting prop', () => { - it('renders the classname "Card hideOnPrint" when passed', () => { - const card = mountWithApp( - -

Some card content.

-
, - ); - - expect(card).toContainReactComponent('div', { - className: 'Card hideOnPrint', - }); - }); - - it('does not render the classname "Card hideOnPrint" when prop is not passed', () => { - const card = mountWithApp( - -

Some card content.

-
, - ); - - expect(card).not.toContainReactComponent('div', { - className: 'Card hideOnPrint', - }); - }); + expect(card).toContainReactComponentTimes('p', 2); }); - it('renders a primary footer action', () => { + it('sets default border radius when roundedAbove breakpoint passed in', () => { + setMediaWidth('breakpoints-sm'); const card = mountWithApp( - -

Some card content.

+ + {heading} + {subheading} , ); - expect(card).toContainReactComponent(Button, {children: 'test action'}); - }); - - describe('secondaryFooterActions', () => { - it('renders a single secondary footer action button when only 1 is supplied', () => { - const card = mountWithApp( - -

Some card content.

-
, - ); - - expect(card).toContainReactComponent(Button, {children: 'test action'}); - expect(card).not.toContainReactComponent(Popover); - }); - - it('renders popover when >1 are supplied', () => { - const card = mountWithApp( - -

Some card content.

-
, - ); - - expect(card).toContainReactComponent(Button, { - children: 'More', - }); - expect(card).toContainReactComponent(Popover); - }); - - it('activates popover when disclosure button is clicked', () => { - const footerActions = [ - {content: 'Most important action'}, - {content: 'Second most important action'}, - ]; - const card = mountWithApp( - -

Some card content.

-
, - ); - const disclosureButton = card.findAll(Button)[0]; - expect(disclosureButton).toContainReactText('More'); - - expect(card).toContainReactComponent(Popover, { - active: false, - }); - - disclosureButton.trigger('onClick'); - - expect(card).toContainReactComponent(Popover, { - active: true, - }); - - expect(card).toContainReactComponent(ActionList, { - items: footerActions, - }); - }); - - it('sets the disclosure button content to the value set on secondaryFooterActionsDisclosureText', () => { - const card = mountWithApp( - -

Some card content.

-
, - ); - - expect(card).toContainReactComponent(Button, { - children: 'Show more', - }); + expect(card).toContainReactComponent('div', { + style: expect.objectContaining({ + '--pc-box-border-radius': 'var(--p-border-radius-2)', + }), }); }); - - it('renders a section when sectioned', () => { - const card = mountWithApp( - -

Some card content.

-
, - ); - - // eslint-disable-next-line import/no-deprecated - expect(card.find(Section)).toContainReactText('Some card content.'); - }); }); diff --git a/polaris-react/src/components/CheckableButton/CheckableButton.scss b/polaris-react/src/components/CheckableButton/CheckableButton.scss index d81233e7e94..681348f68bb 100644 --- a/polaris-react/src/components/CheckableButton/CheckableButton.scss +++ b/polaris-react/src/components/CheckableButton/CheckableButton.scss @@ -8,8 +8,6 @@ font-size: var(--p-font-size-75); font-weight: var(--p-font-weight-medium); line-height: var(--p-font-line-height-1); - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - text-transform: initial; letter-spacing: initial; // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY display: flex; diff --git a/polaris-react/src/components/CheckableButton/CheckableButton.tsx b/polaris-react/src/components/CheckableButton/CheckableButton.tsx index 277ec67b855..dc72f90277b 100644 --- a/polaris-react/src/components/CheckableButton/CheckableButton.tsx +++ b/polaris-react/src/components/CheckableButton/CheckableButton.tsx @@ -1,4 +1,4 @@ -import React, {useRef, useImperativeHandle, forwardRef} from 'react'; +import { useRef, useImperativeHandle, forwardRef } from 'react'; import type {CheckboxHandles} from '../../types'; import {classNames} from '../../utilities/css'; diff --git a/polaris-react/src/components/CheckableButton/tests/CheckableButton.test.tsx b/polaris-react/src/components/CheckableButton/tests/CheckableButton.test.tsx index b9b2f0bd393..7ae01f6fc54 100644 --- a/polaris-react/src/components/CheckableButton/tests/CheckableButton.test.tsx +++ b/polaris-react/src/components/CheckableButton/tests/CheckableButton.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Checkbox} from '../../Checkbox'; diff --git a/polaris-react/src/components/Checkbox/Checkbox.stories.tsx b/polaris-react/src/components/Checkbox/Checkbox.stories.tsx index 16bfcccace4..3e30010a8b6 100644 --- a/polaris-react/src/components/Checkbox/Checkbox.stories.tsx +++ b/polaris-react/src/components/Checkbox/Checkbox.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useState} from 'react'; +import { useCallback, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import {Checkbox} from '@shopify/polaris'; diff --git a/polaris-react/src/components/Checkbox/Checkbox.tsx b/polaris-react/src/components/Checkbox/Checkbox.tsx index 9536074a7d6..5cc8f7b35e3 100644 --- a/polaris-react/src/components/Checkbox/Checkbox.tsx +++ b/polaris-react/src/components/Checkbox/Checkbox.tsx @@ -1,14 +1,14 @@ -import React, { +import { forwardRef, useRef, useImperativeHandle, useContext, + useId, } from 'react'; import {MinusMinor, TickSmallMinor} from '@shopify/polaris-icons'; import {classNames} from '../../utilities/css'; import {useToggle} from '../../utilities/use-toggle'; -import {useUniqueId} from '../../utilities/unique-id'; import {Choice, helpTextID} from '../Choice'; import {errorTextID} from '../InlineError'; import {Icon} from '../Icon'; @@ -69,7 +69,8 @@ export const Checkbox = forwardRef( ref, ) { const inputNode = useRef(null); - const id = useUniqueId('Checkbox', idProp); + const uniqId = useId(); + const id = idProp ?? uniqId; const { value: mouseOver, setTrue: handleMouseOver, diff --git a/polaris-react/src/components/Checkbox/tests/Checkbox.test.tsx b/polaris-react/src/components/Checkbox/tests/Checkbox.test.tsx index 2b4f9e25fd7..3d36ee5fee8 100644 --- a/polaris-react/src/components/Checkbox/tests/Checkbox.test.tsx +++ b/polaris-react/src/components/Checkbox/tests/Checkbox.test.tsx @@ -1,4 +1,4 @@ -import React, {AllHTMLAttributes} from 'react'; +import { AllHTMLAttributes } from 'react'; import {mountWithApp} from 'tests/utilities'; import {Checkbox} from '../Checkbox'; @@ -102,7 +102,7 @@ describe('', () => { const element = mountWithApp(); expect(element).toContainReactComponent('input', { - id: 'PolarisCheckbox1', + id: ':r8:', }); }); }); @@ -138,7 +138,7 @@ describe('', () => { ); expect(checkbox).toContainReactComponent('input', { - 'aria-describedby': 'PolarisCheckbox1HelpText', + 'aria-describedby': ':rc:HelpText', }); expect(checkbox.find('div')).toContainReactText('Some help'); @@ -168,7 +168,7 @@ describe('', () => { ); expect(checkbox).toContainReactComponent('input', { - 'aria-describedby': 'PolarisCheckbox1Error', + 'aria-describedby': ':re:Error', }); expect(checkbox.find('div')).toContainReactText('Some error'); @@ -188,7 +188,7 @@ describe('', () => { ); expect(checkbox).toContainReactComponent('input', { - 'aria-describedby': 'PolarisCheckbox1Error PolarisCheckbox1HelpText', + 'aria-describedby': ':rg:Error :rg:HelpText', }); expect(checkbox.find('div')).toContainReactText('Some error'); expect(checkbox.find('div')).toContainReactText('Some help'); diff --git a/polaris-react/src/components/Choice/Choice.tsx b/polaris-react/src/components/Choice/Choice.tsx index 86a0314f534..cde35dfdb69 100644 --- a/polaris-react/src/components/Choice/Choice.tsx +++ b/polaris-react/src/components/Choice/Choice.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {classNames} from '../../utilities/css'; import type {Error} from '../../types'; import {InlineError} from '../InlineError'; diff --git a/polaris-react/src/components/Choice/tests/Choice.test.tsx b/polaris-react/src/components/Choice/tests/Choice.test.tsx index 5c108f0e9d7..dcc7853acd9 100644 --- a/polaris-react/src/components/Choice/tests/Choice.test.tsx +++ b/polaris-react/src/components/Choice/tests/Choice.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {InlineError} from '../../InlineError'; diff --git a/polaris-react/src/components/ChoiceList/ChoiceList.stories.tsx b/polaris-react/src/components/ChoiceList/ChoiceList.stories.tsx index 4b191f6bc2a..2f47d460925 100644 --- a/polaris-react/src/components/ChoiceList/ChoiceList.stories.tsx +++ b/polaris-react/src/components/ChoiceList/ChoiceList.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useState} from 'react'; +import { useCallback, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import {ChoiceList, TextField} from '@shopify/polaris'; diff --git a/polaris-react/src/components/ChoiceList/ChoiceList.tsx b/polaris-react/src/components/ChoiceList/ChoiceList.tsx index 2ef38e364a5..8b29e22301b 100644 --- a/polaris-react/src/components/ChoiceList/ChoiceList.tsx +++ b/polaris-react/src/components/ChoiceList/ChoiceList.tsx @@ -1,11 +1,10 @@ -import React from 'react'; +import {useId} from 'react'; -import {useUniqueId} from '../../utilities/unique-id'; import type {Error} from '../../types'; import {Checkbox} from '../Checkbox'; import {RadioButton} from '../RadioButton'; import {InlineError, errorTextID} from '../InlineError'; -import {AlphaStack} from '../AlphaStack'; +import {Stack} from '../Stack'; import {Box} from '../Box'; import {Bleed} from '../Bleed'; @@ -64,7 +63,8 @@ export function ChoiceList({ // see https://github.com/Microsoft/TypeScript/issues/28768 const ControlComponent: any = allowMultiple ? Checkbox : RadioButton; - const name = useUniqueId('ChoiceList', nameProp); + const uniqName = useId(); + const name = nameProp ?? uniqName; const finalName = allowMultiple ? `${name}[]` : name; const titleMarkup = title ? ( @@ -132,18 +132,18 @@ export function ChoiceList({ ); return ( - {titleMarkup} - + {choicesMarkup} - + {errorMarkup} - + ); } diff --git a/polaris-react/src/components/ChoiceList/tests/ChoiceList.test.tsx b/polaris-react/src/components/ChoiceList/tests/ChoiceList.test.tsx index e7871884cfc..617eab31528 100644 --- a/polaris-react/src/components/ChoiceList/tests/ChoiceList.test.tsx +++ b/polaris-react/src/components/ChoiceList/tests/ChoiceList.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Bleed} from '../../Bleed'; diff --git a/polaris-react/src/components/Collapsible/Collapsible.stories.tsx b/polaris-react/src/components/Collapsible/Collapsible.stories.tsx index c63358f351e..3c538999ccf 100644 --- a/polaris-react/src/components/Collapsible/Collapsible.stories.tsx +++ b/polaris-react/src/components/Collapsible/Collapsible.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useState} from 'react'; +import { useCallback, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import { Button, diff --git a/polaris-react/src/components/Collapsible/Collapsible.tsx b/polaris-react/src/components/Collapsible/Collapsible.tsx index b08acbab7ef..5f31340922d 100644 --- a/polaris-react/src/components/Collapsible/Collapsible.tsx +++ b/polaris-react/src/components/Collapsible/Collapsible.tsx @@ -1,4 +1,4 @@ -import React, {useState, useRef, useEffect, useCallback} from 'react'; +import {useState, useRef, useEffect, useCallback} from 'react'; import {classNames} from '../../utilities/css'; @@ -22,8 +22,6 @@ export interface CollapsibleProps { * @default transition={{duration: 'var(--p-duration-150)', timingFunction: 'var(--p-ease-in-out)'}} */ transition?: boolean | Transition; - /** @deprecated Re-measuring is no longer necessary on children update **/ - preventMeasuringOnChildrenUpdate?: boolean; /** Callback when the animation completes. */ onAnimationEnd?(): void; /** The content to display inside the collapsible. */ @@ -37,7 +35,6 @@ export function Collapsible({ expandOnPrint, open, transition = true, - preventMeasuringOnChildrenUpdate: _preventMeasuringOnChildrenUpdate, children, onAnimationEnd, }: CollapsibleProps) { diff --git a/polaris-react/src/components/Collapsible/tests/Collapsible.test.tsx b/polaris-react/src/components/Collapsible/tests/Collapsible.test.tsx index 5f721b3878b..37cf392a86d 100644 --- a/polaris-react/src/components/Collapsible/tests/Collapsible.test.tsx +++ b/polaris-react/src/components/Collapsible/tests/Collapsible.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {CustomRoot, mountWithApp} from 'tests/utilities'; import type {WithPolarisTestProviderOptions} from '../../PolarisTestProvider'; diff --git a/polaris-react/src/components/ColorPicker/ColorPicker.stories.tsx b/polaris-react/src/components/ColorPicker/ColorPicker.stories.tsx index 237fc4cbf54..9bb2fedd6ef 100644 --- a/polaris-react/src/components/ColorPicker/ColorPicker.stories.tsx +++ b/polaris-react/src/components/ColorPicker/ColorPicker.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useEffect, useState} from 'react'; +import { useCallback, useEffect, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import { ColorPicker, diff --git a/polaris-react/src/components/ColorPicker/ColorPicker.tsx b/polaris-react/src/components/ColorPicker/ColorPicker.tsx index 91f279e3c4d..68caabd913b 100644 --- a/polaris-react/src/components/ColorPicker/ColorPicker.tsx +++ b/polaris-react/src/components/ColorPicker/ColorPicker.tsx @@ -1,4 +1,4 @@ -import React, {PureComponent} from 'react'; +import {PureComponent} from 'react'; import {debounce} from '../../utilities/debounce'; import {clamp} from '../../utilities/clamp'; diff --git a/polaris-react/src/components/ColorPicker/components/AlphaPicker/AlphaPicker.tsx b/polaris-react/src/components/ColorPicker/components/AlphaPicker/AlphaPicker.tsx index d5a5913a940..41e8e5f2a7f 100644 --- a/polaris-react/src/components/ColorPicker/components/AlphaPicker/AlphaPicker.tsx +++ b/polaris-react/src/components/ColorPicker/components/AlphaPicker/AlphaPicker.tsx @@ -1,4 +1,4 @@ -import React, {PureComponent} from 'react'; +import { PureComponent } from 'react'; import {Slidable, SlidableProps} from '../Slidable'; import type {HSBColor} from '../../../../utilities/color-types'; diff --git a/polaris-react/src/components/ColorPicker/components/AlphaPicker/tests/AlphaPicker.test.tsx b/polaris-react/src/components/ColorPicker/components/AlphaPicker/tests/AlphaPicker.test.tsx index b1ae4399efb..00df9c5502f 100644 --- a/polaris-react/src/components/ColorPicker/components/AlphaPicker/tests/AlphaPicker.test.tsx +++ b/polaris-react/src/components/ColorPicker/components/AlphaPicker/tests/AlphaPicker.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {calculateDraggerY, alphaForDraggerY} from '../utilities'; diff --git a/polaris-react/src/components/ColorPicker/components/HuePicker/HuePicker.tsx b/polaris-react/src/components/ColorPicker/components/HuePicker/HuePicker.tsx index 042b77951ca..dd7a3aba7ce 100644 --- a/polaris-react/src/components/ColorPicker/components/HuePicker/HuePicker.tsx +++ b/polaris-react/src/components/ColorPicker/components/HuePicker/HuePicker.tsx @@ -1,4 +1,4 @@ -import React, {PureComponent} from 'react'; +import { PureComponent } from 'react'; import {Slidable, SlidableProps} from '../Slidable'; import styles from '../../ColorPicker.scss'; diff --git a/polaris-react/src/components/ColorPicker/components/HuePicker/tests/HuePicker.test.tsx b/polaris-react/src/components/ColorPicker/components/HuePicker/tests/HuePicker.test.tsx index 029c02de628..b64a8142e09 100644 --- a/polaris-react/src/components/ColorPicker/components/HuePicker/tests/HuePicker.test.tsx +++ b/polaris-react/src/components/ColorPicker/components/HuePicker/tests/HuePicker.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {calculateDraggerY, hueForDraggerY} from '../utilities'; diff --git a/polaris-react/src/components/ColorPicker/components/Slidable/Slidable.tsx b/polaris-react/src/components/ColorPicker/components/Slidable/Slidable.tsx index 9ded15e08ea..95db869d318 100644 --- a/polaris-react/src/components/ColorPicker/components/Slidable/Slidable.tsx +++ b/polaris-react/src/components/ColorPicker/components/Slidable/Slidable.tsx @@ -1,4 +1,4 @@ -import React, {PureComponent} from 'react'; +import {PureComponent} from 'react'; import {isServer} from '../../../../utilities/target'; // eslint-disable-next-line import/no-deprecated diff --git a/polaris-react/src/components/ColorPicker/components/Slidable/tests/Slidable.test.tsx b/polaris-react/src/components/ColorPicker/components/Slidable/tests/Slidable.test.tsx index 190772355cb..a24ea71d83f 100644 --- a/polaris-react/src/components/ColorPicker/components/Slidable/tests/Slidable.test.tsx +++ b/polaris-react/src/components/ColorPicker/components/Slidable/tests/Slidable.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Slidable} from '../Slidable'; diff --git a/polaris-react/src/components/ColorPicker/tests/ColorPicker-ssr.test.tsx b/polaris-react/src/components/ColorPicker/tests/ColorPicker-ssr.test.tsx index 8c4ccd5658b..8770932862b 100644 --- a/polaris-react/src/components/ColorPicker/tests/ColorPicker-ssr.test.tsx +++ b/polaris-react/src/components/ColorPicker/tests/ColorPicker-ssr.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Slidable} from '../components'; diff --git a/polaris-react/src/components/ColorPicker/tests/ColorPicker.test.tsx b/polaris-react/src/components/ColorPicker/tests/ColorPicker.test.tsx index 5040d2847ad..57a090e0dc1 100644 --- a/polaris-react/src/components/ColorPicker/tests/ColorPicker.test.tsx +++ b/polaris-react/src/components/ColorPicker/tests/ColorPicker.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; // eslint-disable-next-line import/no-deprecated diff --git a/polaris-react/src/components/Columns/Columns.stories.tsx b/polaris-react/src/components/Columns/Columns.stories.tsx index 1cf12c3880c..fc842743ca3 100644 --- a/polaris-react/src/components/Columns/Columns.stories.tsx +++ b/polaris-react/src/components/Columns/Columns.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import {Button, Columns, Page} from '@shopify/polaris'; import {ChevronLeftMinor, ChevronRightMinor} from '@shopify/polaris-icons'; diff --git a/polaris-react/src/components/Columns/Columns.tsx b/polaris-react/src/components/Columns/Columns.tsx index 51e71e574d2..cb99f6274f7 100644 --- a/polaris-react/src/components/Columns/Columns.tsx +++ b/polaris-react/src/components/Columns/Columns.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {SpacingSpaceScale} from '@shopify/polaris-tokens'; import { diff --git a/polaris-react/src/components/Columns/tests/Columns.test.tsx b/polaris-react/src/components/Columns/tests/Columns.test.tsx index e6def4795f7..b6e96a5bd31 100644 --- a/polaris-react/src/components/Columns/tests/Columns.test.tsx +++ b/polaris-react/src/components/Columns/tests/Columns.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Columns} from '..'; diff --git a/polaris-react/src/components/Combobox/Combobox.stories.tsx b/polaris-react/src/components/Combobox/Combobox.stories.tsx index 8ad74a0c6e5..2c969767a34 100644 --- a/polaris-react/src/components/Combobox/Combobox.stories.tsx +++ b/polaris-react/src/components/Combobox/Combobox.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useMemo, useState} from 'react'; +import { useCallback, useMemo, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import { Combobox, diff --git a/polaris-react/src/components/Combobox/Combobox.tsx b/polaris-react/src/components/Combobox/Combobox.tsx index 7fc82ae142e..68f5a322629 100644 --- a/polaris-react/src/components/Combobox/Combobox.tsx +++ b/polaris-react/src/components/Combobox/Combobox.tsx @@ -1,4 +1,4 @@ -import React, {useState, useCallback, useMemo, Children, useRef} from 'react'; +import {useState, useCallback, useMemo, Children, useRef} from 'react'; import {Popover, PopoverPublicAPI} from '../Popover'; import type {PopoverProps} from '../Popover'; diff --git a/polaris-react/src/components/Combobox/components/TextField/TextField.tsx b/polaris-react/src/components/Combobox/components/TextField/TextField.tsx index 894a948c58c..f2f3232e559 100644 --- a/polaris-react/src/components/Combobox/components/TextField/TextField.tsx +++ b/polaris-react/src/components/Combobox/components/TextField/TextField.tsx @@ -1,7 +1,6 @@ -import React, {useMemo, useCallback, useEffect} from 'react'; +import {useMemo, useId, useCallback, useEffect} from 'react'; import {labelID} from '../../../Label'; -import {useUniqueId} from '../../../../utilities/unique-id'; import {TextField as PolarisTextField} from '../../../TextField'; import type {TextFieldProps} from '../../../TextField'; import {useComboboxTextField} from '../../../../utilities/combobox'; @@ -29,7 +28,7 @@ export function TextField({ onTextFieldBlur, } = comboboxTextFieldContext; - const uniqueId = useUniqueId('ComboboxTextField'); + const uniqueId = useId(); const textFieldId = useMemo(() => idProp || uniqueId, [uniqueId, idProp]); const labelId = useMemo( diff --git a/polaris-react/src/components/Combobox/components/TextField/tests/TextField.test.tsx b/polaris-react/src/components/Combobox/components/TextField/tests/TextField.test.tsx index 4b3cd1dff56..d088de02956 100644 --- a/polaris-react/src/components/Combobox/components/TextField/tests/TextField.test.tsx +++ b/polaris-react/src/components/Combobox/components/TextField/tests/TextField.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {TextField as PolarisTextField} from '../../../../TextField'; diff --git a/polaris-react/src/components/Combobox/tests/Combobox.test.tsx b/polaris-react/src/components/Combobox/tests/Combobox.test.tsx index 5e5c643b695..e2c0e2cf34a 100644 --- a/polaris-react/src/components/Combobox/tests/Combobox.test.tsx +++ b/polaris-react/src/components/Combobox/tests/Combobox.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {TextField} from '../../TextField'; diff --git a/polaris-react/src/components/Connected/Connected.tsx b/polaris-react/src/components/Connected/Connected.tsx index 918fcaacce1..4aefeba13d6 100644 --- a/polaris-react/src/components/Connected/Connected.tsx +++ b/polaris-react/src/components/Connected/Connected.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {Item} from './components'; import styles from './Connected.scss'; diff --git a/polaris-react/src/components/Connected/components/Item/Item.tsx b/polaris-react/src/components/Connected/components/Item/Item.tsx index 109dd70cd18..2fffb781d43 100644 --- a/polaris-react/src/components/Connected/components/Item/Item.tsx +++ b/polaris-react/src/components/Connected/components/Item/Item.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {classNames} from '../../../../utilities/css'; import {useToggle} from '../../../../utilities/use-toggle'; import styles from '../../Connected.scss'; diff --git a/polaris-react/src/components/Connected/tests/Connected.test.tsx b/polaris-react/src/components/Connected/tests/Connected.test.tsx index 61689cd4b60..a3957210ac0 100644 --- a/polaris-react/src/components/Connected/tests/Connected.test.tsx +++ b/polaris-react/src/components/Connected/tests/Connected.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Connected} from '../Connected'; diff --git a/polaris-react/src/components/ContextualSaveBar/ContextualSaveBar.stories.tsx b/polaris-react/src/components/ContextualSaveBar/ContextualSaveBar.stories.tsx index d42e8f5a927..235994a05d4 100644 --- a/polaris-react/src/components/ContextualSaveBar/ContextualSaveBar.stories.tsx +++ b/polaris-react/src/components/ContextualSaveBar/ContextualSaveBar.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import {ContextualSaveBar, Frame} from '@shopify/polaris'; diff --git a/polaris-react/src/components/ContextualSaveBar/tests/ContextualSaveBar.test.tsx b/polaris-react/src/components/ContextualSaveBar/tests/ContextualSaveBar.test.tsx index d2eb83563b9..e6ba5df26ce 100644 --- a/polaris-react/src/components/ContextualSaveBar/tests/ContextualSaveBar.test.tsx +++ b/polaris-react/src/components/ContextualSaveBar/tests/ContextualSaveBar.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mount, mountWithApp} from 'tests/utilities'; import {ContextualSaveBar} from '../ContextualSaveBar'; diff --git a/polaris-react/src/components/DataTable/DataTable.stories.tsx b/polaris-react/src/components/DataTable/DataTable.stories.tsx index 0f0558d20cf..257338b1b02 100644 --- a/polaris-react/src/components/DataTable/DataTable.stories.tsx +++ b/polaris-react/src/components/DataTable/DataTable.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useState} from 'react'; +import { useCallback, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import {LegacyCard, DataTable, Link, Page} from '@shopify/polaris'; diff --git a/polaris-react/src/components/DataTable/DataTable.tsx b/polaris-react/src/components/DataTable/DataTable.tsx index ba3689bb8ad..ea5dab79032 100644 --- a/polaris-react/src/components/DataTable/DataTable.tsx +++ b/polaris-react/src/components/DataTable/DataTable.tsx @@ -1,9 +1,4 @@ -import React, { - PureComponent, - createRef, - ReactNode, - FocusEventHandler, -} from 'react'; +import {PureComponent, createRef, ReactNode, FocusEventHandler} from 'react'; import isEqual from 'react-fast-compare'; import {debounce} from '../../utilities/debounce'; diff --git a/polaris-react/src/components/DataTable/components/Cell/Cell.tsx b/polaris-react/src/components/DataTable/components/Cell/Cell.tsx index 31c615ab8c2..45bdf8024fe 100644 --- a/polaris-react/src/components/DataTable/components/Cell/Cell.tsx +++ b/polaris-react/src/components/DataTable/components/Cell/Cell.tsx @@ -1,4 +1,4 @@ -import React, {FocusEventHandler, useRef} from 'react'; +import {FocusEventHandler, useRef} from 'react'; import {SortAscendingMajor, SortDescendingMajor} from '@shopify/polaris-icons'; import {classNames, variationName} from '../../../../utilities/css'; diff --git a/polaris-react/src/components/DataTable/components/Cell/tests/Cell.test.tsx b/polaris-react/src/components/DataTable/components/Cell/tests/Cell.test.tsx index 87d12c9e4f3..445b535a441 100644 --- a/polaris-react/src/components/DataTable/components/Cell/tests/Cell.test.tsx +++ b/polaris-react/src/components/DataTable/components/Cell/tests/Cell.test.tsx @@ -1,4 +1,4 @@ -import React, {ReactElement} from 'react'; +import { ReactElement } from 'react'; import {SortAscendingMajor, SortDescendingMajor} from '@shopify/polaris-icons'; import {mountWithApp} from 'tests/utilities'; diff --git a/polaris-react/src/components/DataTable/components/Navigation/Navigation.tsx b/polaris-react/src/components/DataTable/components/Navigation/Navigation.tsx index 29d07f1541c..1d93e6ee6e5 100644 --- a/polaris-react/src/components/DataTable/components/Navigation/Navigation.tsx +++ b/polaris-react/src/components/DataTable/components/Navigation/Navigation.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {ChevronLeftMinor, ChevronRightMinor} from '@shopify/polaris-icons'; import {classNames} from '../../../../utilities/css'; diff --git a/polaris-react/src/components/DataTable/components/Navigation/tests/Navigation.test.tsx b/polaris-react/src/components/DataTable/components/Navigation/tests/Navigation.test.tsx index 0b40e61f6d4..e21cf51691f 100644 --- a/polaris-react/src/components/DataTable/components/Navigation/tests/Navigation.test.tsx +++ b/polaris-react/src/components/DataTable/components/Navigation/tests/Navigation.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Button} from '../../../../Button'; diff --git a/polaris-react/src/components/DataTable/tests/DataTable.test.tsx b/polaris-react/src/components/DataTable/tests/DataTable.test.tsx index 56429d38546..69c243cab59 100644 --- a/polaris-react/src/components/DataTable/tests/DataTable.test.tsx +++ b/polaris-react/src/components/DataTable/tests/DataTable.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {timer} from '@shopify/jest-dom-mocks'; import {mountWithApp} from 'tests/utilities'; diff --git a/polaris-react/src/components/DatePicker/DatePicker.stories.tsx b/polaris-react/src/components/DatePicker/DatePicker.stories.tsx index 9a28d0ab406..ee873f93bed 100644 --- a/polaris-react/src/components/DatePicker/DatePicker.stories.tsx +++ b/polaris-react/src/components/DatePicker/DatePicker.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useState} from 'react'; +import { useCallback, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import {DatePicker} from '@shopify/polaris'; diff --git a/polaris-react/src/components/DatePicker/DatePicker.tsx b/polaris-react/src/components/DatePicker/DatePicker.tsx index d1486ad2e2c..09b73ef99ca 100644 --- a/polaris-react/src/components/DatePicker/DatePicker.tsx +++ b/polaris-react/src/components/DatePicker/DatePicker.tsx @@ -1,4 +1,4 @@ -import React, {useState, useEffect, useCallback, useMemo} from 'react'; +import {useState, useEffect, useCallback, useMemo} from 'react'; import {ArrowLeftMinor, ArrowRightMinor} from '@shopify/polaris-icons'; import {Button} from '../Button'; diff --git a/polaris-react/src/components/DatePicker/components/Day/Day.tsx b/polaris-react/src/components/DatePicker/components/Day/Day.tsx index 9061ccbff7d..f22e93db745 100644 --- a/polaris-react/src/components/DatePicker/components/Day/Day.tsx +++ b/polaris-react/src/components/DatePicker/components/Day/Day.tsx @@ -1,4 +1,4 @@ -import React, {useRef, useEffect, memo} from 'react'; +import { useRef, useEffect, memo } from 'react'; import {classNames} from '../../../../utilities/css'; import {isSameDay} from '../../../../utilities/dates'; diff --git a/polaris-react/src/components/DatePicker/components/Day/tests/Day.test.tsx b/polaris-react/src/components/DatePicker/components/Day/tests/Day.test.tsx index 3099a5b0a61..6b99960287f 100644 --- a/polaris-react/src/components/DatePicker/components/Day/tests/Day.test.tsx +++ b/polaris-react/src/components/DatePicker/components/Day/tests/Day.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Day} from '../Day'; diff --git a/polaris-react/src/components/DatePicker/components/Month/Month.tsx b/polaris-react/src/components/DatePicker/components/Month/Month.tsx index 407dea48e7d..362a629acb6 100644 --- a/polaris-react/src/components/DatePicker/components/Month/Month.tsx +++ b/polaris-react/src/components/DatePicker/components/Month/Month.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useMemo} from 'react'; +import { useCallback, useMemo } from 'react'; import {classNames} from '../../../../utilities/css'; import { diff --git a/polaris-react/src/components/DatePicker/components/Month/tests/Month.test.tsx b/polaris-react/src/components/DatePicker/components/Month/tests/Month.test.tsx index 4ac7f00ded9..bcdce98a8e3 100644 --- a/polaris-react/src/components/DatePicker/components/Month/tests/Month.test.tsx +++ b/polaris-react/src/components/DatePicker/components/Month/tests/Month.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Weekday} from '../../Weekday'; diff --git a/polaris-react/src/components/DatePicker/components/Weekday/Weekday.tsx b/polaris-react/src/components/DatePicker/components/Weekday/Weekday.tsx index 0002de28076..714d0e3e1e3 100644 --- a/polaris-react/src/components/DatePicker/components/Weekday/Weekday.tsx +++ b/polaris-react/src/components/DatePicker/components/Weekday/Weekday.tsx @@ -1,4 +1,4 @@ -import React, {memo} from 'react'; +import { memo } from 'react'; import {classNames} from '../../../../utilities/css'; import styles from '../../DatePicker.scss'; diff --git a/polaris-react/src/components/DatePicker/components/Weekday/tests/Weekday.test.tsx b/polaris-react/src/components/DatePicker/components/Weekday/tests/Weekday.test.tsx index e5eff4d3639..3cb6ddb8d48 100644 --- a/polaris-react/src/components/DatePicker/components/Weekday/tests/Weekday.test.tsx +++ b/polaris-react/src/components/DatePicker/components/Weekday/tests/Weekday.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Weekday} from '../Weekday'; diff --git a/polaris-react/src/components/DatePicker/tests/DatePicker.test.tsx b/polaris-react/src/components/DatePicker/tests/DatePicker.test.tsx index 0405ffcd878..313c9be9fea 100644 --- a/polaris-react/src/components/DatePicker/tests/DatePicker.test.tsx +++ b/polaris-react/src/components/DatePicker/tests/DatePicker.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Day, Month, Weekday} from '../components'; diff --git a/polaris-react/src/components/DescriptionList/DescriptionList.stories.tsx b/polaris-react/src/components/DescriptionList/DescriptionList.stories.tsx index 9cbb393acd7..f8649ef631e 100644 --- a/polaris-react/src/components/DescriptionList/DescriptionList.stories.tsx +++ b/polaris-react/src/components/DescriptionList/DescriptionList.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import {DescriptionList} from '@shopify/polaris'; diff --git a/polaris-react/src/components/DescriptionList/DescriptionList.tsx b/polaris-react/src/components/DescriptionList/DescriptionList.tsx index 22870c626ba..d484af793af 100644 --- a/polaris-react/src/components/DescriptionList/DescriptionList.tsx +++ b/polaris-react/src/components/DescriptionList/DescriptionList.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {classNames} from '../../utilities/css'; import {Text} from '../Text'; diff --git a/polaris-react/src/components/DescriptionList/tests/DescriptionList.test.tsx b/polaris-react/src/components/DescriptionList/tests/DescriptionList.test.tsx index d28502a3178..7526dff6af7 100644 --- a/polaris-react/src/components/DescriptionList/tests/DescriptionList.test.tsx +++ b/polaris-react/src/components/DescriptionList/tests/DescriptionList.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {DescriptionList} from '../DescriptionList'; diff --git a/polaris-react/src/components/DisplayText/DisplayText.scss b/polaris-react/src/components/DisplayText/DisplayText.scss deleted file mode 100644 index e8326617cb7..00000000000 --- a/polaris-react/src/components/DisplayText/DisplayText.scss +++ /dev/null @@ -1,25 +0,0 @@ -@import '../../styles/common'; - -.DisplayText { - margin: 0; -} - -.sizeSmall { - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - @include text-style-display-small; -} - -.sizeMedium { - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - @include text-style-display-medium; -} - -.sizeLarge { - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - @include text-style-display-large; -} - -.sizeExtraLarge { - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - @include text-style-display-x-large; -} diff --git a/polaris-react/src/components/DisplayText/DisplayText.stories.tsx b/polaris-react/src/components/DisplayText/DisplayText.stories.tsx deleted file mode 100644 index c8d7b767587..00000000000 --- a/polaris-react/src/components/DisplayText/DisplayText.stories.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React from 'react'; -import type {ComponentMeta} from '@storybook/react'; -import {DisplayText} from '@shopify/polaris'; - -export default { - component: DisplayText, -} as ComponentMeta; - -export function ExtraLarge() { - return Good evening, Dominic.; -} - -export function Large() { - return Good evening, Dominic.; -} - -export function Medium() { - return Good evening, Dominic.; -} - -export function Small() { - return Good evening, Dominic.; -} diff --git a/polaris-react/src/components/DisplayText/DisplayText.tsx b/polaris-react/src/components/DisplayText/DisplayText.tsx deleted file mode 100644 index f0b96464b83..00000000000 --- a/polaris-react/src/components/DisplayText/DisplayText.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import React from 'react'; - -import {classNames, variationName} from '../../utilities/css'; -import type {HeadingTagName} from '../../types'; - -import styles from './DisplayText.scss'; - -type Size = 'small' | 'medium' | 'large' | 'extraLarge'; - -export interface DisplayTextProps { - /** - * Name of element to use for text - * @default 'p' - */ - element?: HeadingTagName; - /** - * Size of the text - * @default 'medium' - */ - size?: Size; - /** Content to display */ - children?: React.ReactNode; -} - -/** - * @deprecated The DisplayText component will be removed in the next - * major version. Use the Text component instead. See the - * Polaris component guide on how to use Text. - * - * https://polaris.shopify.com/components/text - */ -export function DisplayText({ - element: Element = 'p', - children, - size = 'medium', -}: DisplayTextProps) { - const className = classNames( - styles.DisplayText, - size && styles[variationName('size', size)], - ); - - return {children}; -} diff --git a/polaris-react/src/components/DisplayText/index.ts b/polaris-react/src/components/DisplayText/index.ts deleted file mode 100644 index 1688b1c39f6..00000000000 --- a/polaris-react/src/components/DisplayText/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './DisplayText'; diff --git a/polaris-react/src/components/DisplayText/tests/DisplayText.test.tsx b/polaris-react/src/components/DisplayText/tests/DisplayText.test.tsx deleted file mode 100644 index e1fc5169c88..00000000000 --- a/polaris-react/src/components/DisplayText/tests/DisplayText.test.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import React from 'react'; -import {mountWithApp} from 'tests/utilities'; - -// eslint-disable-next-line import/no-deprecated -import {DisplayText} from '../DisplayText'; - -describe('', () => { - it('renders its children', () => { - const text = 'Important text.'; - const displayText = mountWithApp( - - {text} - , - ); - expect(displayText).toContainReactText(text); - }); - - it('renders the specified element', () => { - const displayText = mountWithApp( - - Important text. - , - ); - expect(displayText).toContainReactComponentTimes('h1', 1); - }); - - it('renders a p element if not specified', () => { - const displayText = mountWithApp( - Important text., - ); - - expect(displayText).toContainReactComponentTimes('p', 1); - }); -}); diff --git a/polaris-react/src/components/Divider/Divider.stories.tsx b/polaris-react/src/components/Divider/Divider.stories.tsx index ba02ba42b65..873da58993f 100644 --- a/polaris-react/src/components/Divider/Divider.stories.tsx +++ b/polaris-react/src/components/Divider/Divider.stories.tsx @@ -1,6 +1,5 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; -import {AlphaStack, Divider, Text} from '@shopify/polaris'; +import {Stack, Divider, Text} from '@shopify/polaris'; export default { component: Divider, @@ -12,7 +11,7 @@ export function Default() { export function WithBorderStyles() { return ( - + Base @@ -33,6 +32,6 @@ export function WithBorderStyles() { Transparent - + ); } diff --git a/polaris-react/src/components/Divider/Divider.tsx b/polaris-react/src/components/Divider/Divider.tsx index 9f25fb81fbb..9f74879f5c9 100644 --- a/polaris-react/src/components/Divider/Divider.tsx +++ b/polaris-react/src/components/Divider/Divider.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import styles from './Divider.scss'; export type BorderTokenAlias = diff --git a/polaris-react/src/components/Divider/tests/Divider.test.tsx b/polaris-react/src/components/Divider/tests/Divider.test.tsx index 75d05fe49ea..0deb11b1375 100644 --- a/polaris-react/src/components/Divider/tests/Divider.test.tsx +++ b/polaris-react/src/components/Divider/tests/Divider.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Divider} from '../Divider'; diff --git a/polaris-react/src/components/DropZone/DropZone.stories.tsx b/polaris-react/src/components/DropZone/DropZone.stories.tsx index dca88c81107..e34a10cb1d9 100644 --- a/polaris-react/src/components/DropZone/DropZone.stories.tsx +++ b/polaris-react/src/components/DropZone/DropZone.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useState} from 'react'; +import { useCallback, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import { Banner, @@ -7,7 +7,7 @@ import { DropZone, List, Page, - AlphaStack, + Stack, Thumbnail, Inline, } from '@shopify/polaris'; @@ -31,7 +31,7 @@ export function Default() { const fileUpload = !files.length && ; const uploadedFiles = files.length > 0 && (
- + {files.map((file, index) => ( @@ -52,7 +51,7 @@ export function Default() {
))} - + ); @@ -87,13 +86,12 @@ export function WithImageFileUpload() { const fileUpload = !files.length && ; const uploadedFiles = files.length > 0 && ( - + {files.map((file, index) => (
@@ -104,7 +102,7 @@ export function WithImageFileUpload() {
))} -
+ ); const errorMessage = hasError && ( @@ -123,13 +121,13 @@ export function WithImageFileUpload() { ); return ( - + {errorMessage} {uploadedFiles} {fileUpload} - + ); } @@ -152,8 +150,7 @@ export function WithSingleFileUpload() { alt={file.name} source={ validImageTypes.includes(file.type) - ? // eslint-disable-next-line node/no-unsupported-features/node-builtins - window.URL.createObjectURL(file) + ? window.URL.createObjectURL(file) : NoteMinor } /> @@ -186,7 +183,7 @@ export function WithDropOnPage() { const validImageTypes = ['image/gif', 'image/jpeg', 'image/png']; const uploadedFiles = files.length > 0 && ( - + {files.map((file, index) => ( @@ -207,14 +203,14 @@ export function WithDropOnPage() { ))} - + ); const uploadMessage = !uploadedFiles && ; return ( 0 && ( - + {files.map((file, index) => (
@@ -265,7 +260,7 @@ export function AcceptsOnlySVGFiles() {
))} -
+ ); const errorMessage = hasError && ( @@ -284,7 +279,7 @@ export function AcceptsOnlySVGFiles() { ); return ( - + {errorMessage} {uploadedFiles} - + ); } @@ -311,7 +306,7 @@ export function Nested() { const fileUpload = !files.length && ; const uploadedFiles = files.length > 0 && ( - + {files.map((file, index) => ( @@ -332,7 +326,7 @@ export function Nested() { ))} - + ); return ( @@ -383,7 +377,7 @@ export function WithCustomFileUploadText() { ); const uploadedFiles = files.length > 0 && ( - + {files.map((file, index) => ( @@ -404,7 +397,7 @@ export function WithCustomFileUploadText() { ))} - + ); return ( @@ -432,7 +425,7 @@ export function WithCustomFileDialogTrigger() { const validImageTypes = ['image/gif', 'image/jpeg', 'image/png']; const uploadedFiles = files.length > 0 && ( - + {files.map((file, index) => ( @@ -453,7 +445,7 @@ export function WithCustomFileDialogTrigger() { ))} - + ); return ( diff --git a/polaris-react/src/components/DropZone/DropZone.tsx b/polaris-react/src/components/DropZone/DropZone.tsx index 6cd106663a6..b56a386ca4d 100755 --- a/polaris-react/src/components/DropZone/DropZone.tsx +++ b/polaris-react/src/components/DropZone/DropZone.tsx @@ -1,10 +1,11 @@ -import React, { +import { useState, useRef, useCallback, FunctionComponent, useMemo, useEffect, + useId, } from 'react'; import {UploadMajor, CircleAlertMajor} from '@shopify/polaris-icons'; @@ -16,10 +17,9 @@ import {Text} from '../Text'; import {Labelled, LabelledProps} from '../Labelled'; import {useI18n} from '../../utilities/i18n'; import {isServer} from '../../utilities/target'; -import {useUniqueId} from '../../utilities/unique-id'; import {useComponentDidMount} from '../../utilities/use-component-did-mount'; import {useToggle} from '../../utilities/use-toggle'; -import {AlphaStack} from '../AlphaStack'; +import {Stack} from '../Stack'; import {useEventListener} from '../../utilities/use-event-listener'; import {FileUpload} from './components'; @@ -299,7 +299,8 @@ export const DropZone: React.FunctionComponent & { adjustSize(); }); - const id = useUniqueId('DropZone', idProp); + const uniqId = useId(); + const id = idProp ?? uniqId; const typeSuffix = capitalize(type); const allowMultipleKey = createAllowMultipleKey(allowMultiple); @@ -373,14 +374,14 @@ export const DropZone: React.FunctionComponent & { ) { return (
- + {size === 'small' && } {(size === 'medium' || size === 'large') && ( {text} )} - +
); } diff --git a/polaris-react/src/components/DropZone/components/FileUpload/FileUpload.tsx b/polaris-react/src/components/DropZone/components/FileUpload/FileUpload.tsx index 372c08bbded..d6f66be7b21 100755 --- a/polaris-react/src/components/DropZone/components/FileUpload/FileUpload.tsx +++ b/polaris-react/src/components/DropZone/components/FileUpload/FileUpload.tsx @@ -1,4 +1,4 @@ -import React, {useContext} from 'react'; +import { useContext } from 'react'; import {classNames} from '../../../../utilities/css'; import {capitalize} from '../../../../utilities/capitalize'; @@ -7,7 +7,7 @@ import {uploadArrow} from '../../images'; import {DropZoneContext} from '../../context'; import {useI18n} from '../../../../utilities/i18n'; import {createAllowMultipleKey} from '../../utils'; -import {AlphaStack} from '../../../AlphaStack'; +import {Stack} from '../../../Stack'; import styles from './FileUpload.scss'; @@ -55,18 +55,18 @@ export function FileUpload(props: FileUploadProps) { switch (size) { case 'large': viewMarkup = ( - + {actionMarkup} {actionHintMarkup} - + ); break; case 'medium': viewMarkup = ( - + {actionMarkup} {actionHintMarkup} - + ); break; case 'small': diff --git a/polaris-react/src/components/DropZone/components/FileUpload/tests/FileUpload.test.tsx b/polaris-react/src/components/DropZone/components/FileUpload/tests/FileUpload.test.tsx index dcc44bd234f..8a3723c0bf0 100755 --- a/polaris-react/src/components/DropZone/components/FileUpload/tests/FileUpload.test.tsx +++ b/polaris-react/src/components/DropZone/components/FileUpload/tests/FileUpload.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Text} from '../../../../Text'; diff --git a/polaris-react/src/components/DropZone/tests/DropZone.test.tsx b/polaris-react/src/components/DropZone/tests/DropZone.test.tsx index a2563703af3..b3f01218a5e 100755 --- a/polaris-react/src/components/DropZone/tests/DropZone.test.tsx +++ b/polaris-react/src/components/DropZone/tests/DropZone.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {act} from 'react-dom/test-utils'; import {clock} from '@shopify/jest-dom-mocks'; import {mountWithApp, CustomRoot} from 'tests/utilities'; diff --git a/polaris-react/src/components/EmptySearchResult/EmptySearchResult.tsx b/polaris-react/src/components/EmptySearchResult/EmptySearchResult.tsx index 420accb5b86..951353c2f81 100644 --- a/polaris-react/src/components/EmptySearchResult/EmptySearchResult.tsx +++ b/polaris-react/src/components/EmptySearchResult/EmptySearchResult.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {useI18n} from '../../utilities/i18n'; import {Text} from '../Text'; import {Image} from '../Image'; diff --git a/polaris-react/src/components/EmptySearchResult/tests/EmptySearchResult.test.tsx b/polaris-react/src/components/EmptySearchResult/tests/EmptySearchResult.test.tsx index a8d30b190ab..1d0beb314b1 100644 --- a/polaris-react/src/components/EmptySearchResult/tests/EmptySearchResult.test.tsx +++ b/polaris-react/src/components/EmptySearchResult/tests/EmptySearchResult.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Text} from '../../Text'; diff --git a/polaris-react/src/components/EmptyState/EmptyState.stories.tsx b/polaris-react/src/components/EmptyState/EmptyState.stories.tsx index 170c8d730d8..e3e680c693e 100644 --- a/polaris-react/src/components/EmptyState/EmptyState.stories.tsx +++ b/polaris-react/src/components/EmptyState/EmptyState.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import {LegacyCard, EmptyState, Link} from '@shopify/polaris'; diff --git a/polaris-react/src/components/EmptyState/EmptyState.tsx b/polaris-react/src/components/EmptyState/EmptyState.tsx index 6471b7e4dd0..d278d0e09d7 100644 --- a/polaris-react/src/components/EmptyState/EmptyState.tsx +++ b/polaris-react/src/components/EmptyState/EmptyState.tsx @@ -1,4 +1,4 @@ -import React, {useContext} from 'react'; +import {useContext} from 'react'; import {classNames} from '../../utilities/css'; import {WithinContentContext} from '../../utilities/within-content-context'; @@ -7,7 +7,7 @@ import {Box} from '../Box'; import {buttonFrom} from '../Button'; import {Image} from '../Image'; import {Text} from '../Text'; -import {AlphaStack} from '../AlphaStack'; +import {Stack} from '../Stack'; import {Inline} from '../Inline'; import styles from './EmptyState.scss'; @@ -124,11 +124,11 @@ export function EmptyState({ const detailsMarkup = textContentMarkup || actionsMarkup || footerContentMarkup ? ( - + {textContentMarkup} {actionsMarkup} {footerContentMarkup} - + ) : null; @@ -139,10 +139,10 @@ export function EmptyState({ paddingBlockStart="5" paddingBlockEnd="16" > - + {imageMarkup} {detailsMarkup} - + ); } diff --git a/polaris-react/src/components/EmptyState/tests/EmptyState.test.tsx b/polaris-react/src/components/EmptyState/tests/EmptyState.test.tsx index 6e616e2f21f..2607d007a5a 100644 --- a/polaris-react/src/components/EmptyState/tests/EmptyState.test.tsx +++ b/polaris-react/src/components/EmptyState/tests/EmptyState.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Button} from '../../Button'; diff --git a/polaris-react/src/components/EphemeralPresenceManager/EphemeralPresenceManager.tsx b/polaris-react/src/components/EphemeralPresenceManager/EphemeralPresenceManager.tsx index d091a5fcefd..05cda6f34d4 100644 --- a/polaris-react/src/components/EphemeralPresenceManager/EphemeralPresenceManager.tsx +++ b/polaris-react/src/components/EphemeralPresenceManager/EphemeralPresenceManager.tsx @@ -1,4 +1,4 @@ -import React, {useMemo, useState, useCallback, ContextType} from 'react'; +import {useMemo, useState, useCallback, ContextType} from 'react'; import {EphemeralPresenceManagerContext} from '../../utilities/ephemeral-presence-manager'; import type {EphemeralPresenceKey} from '../../utilities/ephemeral-presence-manager'; diff --git a/polaris-react/src/components/EphemeralPresenceManager/tests/EphemeralPresenceManager.test.tsx b/polaris-react/src/components/EphemeralPresenceManager/tests/EphemeralPresenceManager.test.tsx index cec91d1af32..9a441e3402b 100644 --- a/polaris-react/src/components/EphemeralPresenceManager/tests/EphemeralPresenceManager.test.tsx +++ b/polaris-react/src/components/EphemeralPresenceManager/tests/EphemeralPresenceManager.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {useEphemeralPresenceManager} from '../../../utilities/ephemeral-presence-manager'; diff --git a/polaris-react/src/components/EventListener/tests/EventListener.test.tsx b/polaris-react/src/components/EventListener/tests/EventListener.test.tsx index 88d4248f2d4..e5f210929e3 100644 --- a/polaris-react/src/components/EventListener/tests/EventListener.test.tsx +++ b/polaris-react/src/components/EventListener/tests/EventListener.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; // eslint-disable-next-line import/no-deprecated diff --git a/polaris-react/src/components/ExceptionList/ExceptionList.stories.tsx b/polaris-react/src/components/ExceptionList/ExceptionList.stories.tsx index 5386404aabe..c087493db2e 100644 --- a/polaris-react/src/components/ExceptionList/ExceptionList.stories.tsx +++ b/polaris-react/src/components/ExceptionList/ExceptionList.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import {ExceptionList} from '@shopify/polaris'; import {NoteMinor} from '@shopify/polaris-icons'; diff --git a/polaris-react/src/components/ExceptionList/ExceptionList.tsx b/polaris-react/src/components/ExceptionList/ExceptionList.tsx index 78eb8d57fc2..8dab9f5d67e 100644 --- a/polaris-react/src/components/ExceptionList/ExceptionList.tsx +++ b/polaris-react/src/components/ExceptionList/ExceptionList.tsx @@ -1,4 +1,4 @@ -import React, {Fragment} from 'react'; +import {Fragment} from 'react'; import {classNames, variationName} from '../../utilities/css'; import {Icon, IconProps} from '../Icon'; diff --git a/polaris-react/src/components/ExceptionList/tests/ExceptionList.test.tsx b/polaris-react/src/components/ExceptionList/tests/ExceptionList.test.tsx index e565006c37f..29e37591577 100644 --- a/polaris-react/src/components/ExceptionList/tests/ExceptionList.test.tsx +++ b/polaris-react/src/components/ExceptionList/tests/ExceptionList.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {CirclePlusMinor, NoteMinor} from '@shopify/polaris-icons'; import {mountWithApp} from 'tests/utilities'; diff --git a/polaris-react/src/components/Filters/Filters.stories.tsx b/polaris-react/src/components/Filters/Filters.stories.tsx index 86730115a44..f86ad524016 100644 --- a/polaris-react/src/components/Filters/Filters.stories.tsx +++ b/polaris-react/src/components/Filters/Filters.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useState} from 'react'; +import { useCallback, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import { Avatar, diff --git a/polaris-react/src/components/Filters/Filters.tsx b/polaris-react/src/components/Filters/Filters.tsx index bcba17bfe4b..101029107e5 100644 --- a/polaris-react/src/components/Filters/Filters.tsx +++ b/polaris-react/src/components/Filters/Filters.tsx @@ -1,4 +1,4 @@ -import React, {Component, createRef} from 'react'; +import {Component, createRef} from 'react'; import { SearchMinor, ChevronUpMinor, diff --git a/polaris-react/src/components/Filters/components/ConnectedFilterControl/ConnectedFilterControl.tsx b/polaris-react/src/components/Filters/components/ConnectedFilterControl/ConnectedFilterControl.tsx index 0c2c186e606..c46f6181c5f 100644 --- a/polaris-react/src/components/Filters/components/ConnectedFilterControl/ConnectedFilterControl.tsx +++ b/polaris-react/src/components/Filters/components/ConnectedFilterControl/ConnectedFilterControl.tsx @@ -1,4 +1,4 @@ -import React, {Component, createRef} from 'react'; +import {Component, createRef} from 'react'; import {debounce} from '../../../../utilities/debounce'; import {classNames} from '../../../../utilities/css'; diff --git a/polaris-react/src/components/Filters/components/ConnectedFilterControl/components/Item/Item.tsx b/polaris-react/src/components/Filters/components/ConnectedFilterControl/components/Item/Item.tsx index 11406094383..ebb370eda72 100644 --- a/polaris-react/src/components/Filters/components/ConnectedFilterControl/components/Item/Item.tsx +++ b/polaris-react/src/components/Filters/components/ConnectedFilterControl/components/Item/Item.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {classNames} from '../../../../../../utilities/css'; import {useToggle} from '../../../../../../utilities/use-toggle'; import styles from '../../ConnectedFilterControl.scss'; diff --git a/polaris-react/src/components/Filters/components/ConnectedFilterControl/components/Item/tests/Item.test.tsx b/polaris-react/src/components/Filters/components/ConnectedFilterControl/components/Item/tests/Item.test.tsx index 7e5c00c33b3..bf54902b44b 100644 --- a/polaris-react/src/components/Filters/components/ConnectedFilterControl/components/Item/tests/Item.test.tsx +++ b/polaris-react/src/components/Filters/components/ConnectedFilterControl/components/Item/tests/Item.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Item} from '../Item'; diff --git a/polaris-react/src/components/Filters/components/ConnectedFilterControl/tests/ConnectedFilterControl.test.tsx b/polaris-react/src/components/Filters/components/ConnectedFilterControl/tests/ConnectedFilterControl.test.tsx index 3ddf5451ad2..711f010de91 100644 --- a/polaris-react/src/components/Filters/components/ConnectedFilterControl/tests/ConnectedFilterControl.test.tsx +++ b/polaris-react/src/components/Filters/components/ConnectedFilterControl/tests/ConnectedFilterControl.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Button} from '../../../../Button'; diff --git a/polaris-react/src/components/Filters/components/TagsWrapper/TagsWrapper.tsx b/polaris-react/src/components/Filters/components/TagsWrapper/TagsWrapper.tsx index 41e32308780..9e99984b1a7 100644 --- a/polaris-react/src/components/Filters/components/TagsWrapper/TagsWrapper.tsx +++ b/polaris-react/src/components/Filters/components/TagsWrapper/TagsWrapper.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {Text} from '../../../Text'; interface Props { diff --git a/polaris-react/src/components/Filters/components/TagsWrapper/tests/TagsWrapper.test.tsx b/polaris-react/src/components/Filters/components/TagsWrapper/tests/TagsWrapper.test.tsx index 9bb1d8c0994..e056c6914a6 100644 --- a/polaris-react/src/components/Filters/components/TagsWrapper/tests/TagsWrapper.test.tsx +++ b/polaris-react/src/components/Filters/components/TagsWrapper/tests/TagsWrapper.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {TagsWrapper} from '../TagsWrapper'; diff --git a/polaris-react/src/components/Filters/tests/Filters.test.tsx b/polaris-react/src/components/Filters/tests/Filters.test.tsx index 0d5e3436027..93a1adbae05 100644 --- a/polaris-react/src/components/Filters/tests/Filters.test.tsx +++ b/polaris-react/src/components/Filters/tests/Filters.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {matchMedia} from '@shopify/jest-dom-mocks'; import {mountWithApp} from 'tests/utilities'; diff --git a/polaris-react/src/components/Focus/Focus.tsx b/polaris-react/src/components/Focus/Focus.tsx index 349565f8c1c..cd6c72a45bc 100644 --- a/polaris-react/src/components/Focus/Focus.tsx +++ b/polaris-react/src/components/Focus/Focus.tsx @@ -1,4 +1,4 @@ -import React, {memo, useEffect} from 'react'; +import {memo, useEffect} from 'react'; import {focusFirstFocusableNode} from '../../utilities/focus'; diff --git a/polaris-react/src/components/Focus/tests/Focus.test.tsx b/polaris-react/src/components/Focus/tests/Focus.test.tsx index 620f9a913a3..bf21d54e21f 100644 --- a/polaris-react/src/components/Focus/tests/Focus.test.tsx +++ b/polaris-react/src/components/Focus/tests/Focus.test.tsx @@ -1,4 +1,4 @@ -import React, {useRef, useState, useEffect} from 'react'; +import { useRef, useState, useEffect } from 'react'; import {mountWithApp} from 'tests/utilities'; import {Focus, FocusProps} from '../Focus'; diff --git a/polaris-react/src/components/FocusManager/FocusManager.tsx b/polaris-react/src/components/FocusManager/FocusManager.tsx index 892b0af2b83..9bfb3e73dc7 100644 --- a/polaris-react/src/components/FocusManager/FocusManager.tsx +++ b/polaris-react/src/components/FocusManager/FocusManager.tsx @@ -1,4 +1,4 @@ -import React, {useMemo, useState, useCallback, ContextType} from 'react'; +import {useMemo, useState, useCallback, ContextType} from 'react'; import {FocusManagerContext} from '../../utilities/focus-manager'; diff --git a/polaris-react/src/components/FocusManager/tests/FocusManager.test.tsx b/polaris-react/src/components/FocusManager/tests/FocusManager.test.tsx index cde5449b141..3a9929da271 100644 --- a/polaris-react/src/components/FocusManager/tests/FocusManager.test.tsx +++ b/polaris-react/src/components/FocusManager/tests/FocusManager.test.tsx @@ -1,4 +1,4 @@ -import React, {useContext, useEffect, useRef} from 'react'; +import { useContext, useEffect, useRef } from 'react'; import {mountWithApp} from 'tests/utilities'; import { diff --git a/polaris-react/src/components/FooterHelp/FooterHelp.scss b/polaris-react/src/components/FooterHelp/FooterHelp.scss index 739c0e642e9..80e3b5c2875 100644 --- a/polaris-react/src/components/FooterHelp/FooterHelp.scss +++ b/polaris-react/src/components/FooterHelp/FooterHelp.scss @@ -21,7 +21,5 @@ font-weight: var(--p-font-weight-regular); line-height: var(--p-font-line-height-2); border: none; - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - text-transform: initial; letter-spacing: initial; } diff --git a/polaris-react/src/components/FooterHelp/FooterHelp.stories.tsx b/polaris-react/src/components/FooterHelp/FooterHelp.stories.tsx index 4e3b89148b1..1c2bf221cae 100644 --- a/polaris-react/src/components/FooterHelp/FooterHelp.stories.tsx +++ b/polaris-react/src/components/FooterHelp/FooterHelp.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import {FooterHelp, Link} from '@shopify/polaris'; diff --git a/polaris-react/src/components/FooterHelp/FooterHelp.tsx b/polaris-react/src/components/FooterHelp/FooterHelp.tsx index 757f818da3a..3f662c450ca 100644 --- a/polaris-react/src/components/FooterHelp/FooterHelp.tsx +++ b/polaris-react/src/components/FooterHelp/FooterHelp.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import styles from './FooterHelp.scss'; export interface FooterHelpProps { diff --git a/polaris-react/src/components/FooterHelp/tests/FooterHelp.test.tsx b/polaris-react/src/components/FooterHelp/tests/FooterHelp.test.tsx index 1a0c27f18ca..47db2cbb393 100644 --- a/polaris-react/src/components/FooterHelp/tests/FooterHelp.test.tsx +++ b/polaris-react/src/components/FooterHelp/tests/FooterHelp.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {FooterHelp} from '../FooterHelp'; diff --git a/polaris-react/src/components/Form/Form.stories.tsx b/polaris-react/src/components/Form/Form.stories.tsx index ab957bc0417..643bce1ddef 100644 --- a/polaris-react/src/components/Form/Form.stories.tsx +++ b/polaris-react/src/components/Form/Form.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useState} from 'react'; +import { useCallback, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import {Button, Checkbox, Form, FormLayout, TextField} from '@shopify/polaris'; diff --git a/polaris-react/src/components/Form/Form.tsx b/polaris-react/src/components/Form/Form.tsx index c12b01f3188..54c6f4e4d33 100644 --- a/polaris-react/src/components/Form/Form.tsx +++ b/polaris-react/src/components/Form/Form.tsx @@ -1,4 +1,4 @@ -import React, {useCallback} from 'react'; +import {useCallback} from 'react'; import {Text} from '../Text'; import {useI18n} from '../../utilities/i18n'; diff --git a/polaris-react/src/components/Form/tests/Form.test.tsx b/polaris-react/src/components/Form/tests/Form.test.tsx index 74569b159f0..f7b29add454 100644 --- a/polaris-react/src/components/Form/tests/Form.test.tsx +++ b/polaris-react/src/components/Form/tests/Form.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Form} from '../Form'; diff --git a/polaris-react/src/components/FormLayout/FormLayout.stories.tsx b/polaris-react/src/components/FormLayout/FormLayout.stories.tsx index 3b942de95ad..8713be977b4 100644 --- a/polaris-react/src/components/FormLayout/FormLayout.stories.tsx +++ b/polaris-react/src/components/FormLayout/FormLayout.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import {FormLayout, TextField} from '@shopify/polaris'; diff --git a/polaris-react/src/components/FormLayout/FormLayout.tsx b/polaris-react/src/components/FormLayout/FormLayout.tsx index 5a70a91aa64..a1e18fe14c4 100644 --- a/polaris-react/src/components/FormLayout/FormLayout.tsx +++ b/polaris-react/src/components/FormLayout/FormLayout.tsx @@ -1,4 +1,4 @@ -import React, {memo, Children, NamedExoticComponent} from 'react'; +import {memo, Children, NamedExoticComponent} from 'react'; import {wrapWithComponent, isElementOfType} from '../../utilities/components'; diff --git a/polaris-react/src/components/FormLayout/components/Group/Group.tsx b/polaris-react/src/components/FormLayout/components/Group/Group.tsx index b2093e21500..3b09ea59979 100644 --- a/polaris-react/src/components/FormLayout/components/Group/Group.tsx +++ b/polaris-react/src/components/FormLayout/components/Group/Group.tsx @@ -1,8 +1,7 @@ -import React, {Children} from 'react'; +import {Children, useId} from 'react'; import {classNames} from '../../../../utilities/css'; import {wrapWithComponent} from '../../../../utilities/components'; -import {useUniqueId} from '../../../../utilities/unique-id'; import {Box} from '../../../Box'; import {Item} from '../Item'; import styles from '../../FormLayout.scss'; @@ -17,7 +16,7 @@ export interface GroupProps { export function Group({children, condensed, title, helpText}: GroupProps) { const className = classNames(condensed ? styles.condensed : styles.grouped); - const id = useUniqueId('FormLayoutGroup'); + const id = useId(); let helpTextElement = null; let helpTextID: undefined | string; diff --git a/polaris-react/src/components/FormLayout/components/Group/tests/Group.test.tsx b/polaris-react/src/components/FormLayout/components/Group/tests/Group.test.tsx index 6961cb501b2..6a283db1886 100644 --- a/polaris-react/src/components/FormLayout/components/Group/tests/Group.test.tsx +++ b/polaris-react/src/components/FormLayout/components/Group/tests/Group.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {TextField} from '../../../../TextField'; diff --git a/polaris-react/src/components/FormLayout/components/Item/Item.tsx b/polaris-react/src/components/FormLayout/components/Item/Item.tsx index 1f9a61c5793..9de7e7b3f4a 100644 --- a/polaris-react/src/components/FormLayout/components/Item/Item.tsx +++ b/polaris-react/src/components/FormLayout/components/Item/Item.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import styles from '../../FormLayout.scss'; export interface ItemProps { diff --git a/polaris-react/src/components/FormLayout/components/Item/tests/Item.test.tsx b/polaris-react/src/components/FormLayout/components/Item/tests/Item.test.tsx index abf39d90047..fe9451b674a 100644 --- a/polaris-react/src/components/FormLayout/components/Item/tests/Item.test.tsx +++ b/polaris-react/src/components/FormLayout/components/Item/tests/Item.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import styles from '../../../FormLayout.scss'; diff --git a/polaris-react/src/components/FormLayout/tests/FormLayout.test.tsx b/polaris-react/src/components/FormLayout/tests/FormLayout.test.tsx index b36d06d9f46..6d601f55672 100644 --- a/polaris-react/src/components/FormLayout/tests/FormLayout.test.tsx +++ b/polaris-react/src/components/FormLayout/tests/FormLayout.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {TextField} from '../../TextField'; diff --git a/polaris-react/src/components/Frame/Frame.scss b/polaris-react/src/components/Frame/Frame.scss index dd47e004f4b..cfe3984486f 100644 --- a/polaris-react/src/components/Frame/Frame.scss +++ b/polaris-react/src/components/Frame/Frame.scss @@ -333,8 +333,6 @@ font-size: var(--p-font-size-100); font-weight: var(--p-font-weight-medium); line-height: var(--p-font-line-height-1); - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - text-transform: initial; letter-spacing: initial; color: var(--p-text); diff --git a/polaris-react/src/components/Frame/Frame.stories.tsx b/polaris-react/src/components/Frame/Frame.stories.tsx index da3b906f177..fde70f2dedf 100644 --- a/polaris-react/src/components/Frame/Frame.stories.tsx +++ b/polaris-react/src/components/Frame/Frame.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useRef, useState} from 'react'; +import { useCallback, useRef, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import { ActionList, diff --git a/polaris-react/src/components/Frame/Frame.tsx b/polaris-react/src/components/Frame/Frame.tsx index 0a9b2678ce3..3f42499638a 100644 --- a/polaris-react/src/components/Frame/Frame.tsx +++ b/polaris-react/src/components/Frame/Frame.tsx @@ -1,4 +1,4 @@ -import React, {PureComponent, createRef, MouseEvent} from 'react'; +import {PureComponent, createRef, MouseEvent} from 'react'; import {MobileCancelMajor} from '@shopify/polaris-icons'; import {CSSTransition} from 'react-transition-group'; import {motion} from '@shopify/polaris-tokens'; diff --git a/polaris-react/src/components/Frame/components/CSSAnimation/CSSAnimation.tsx b/polaris-react/src/components/Frame/components/CSSAnimation/CSSAnimation.tsx index d3bb023017b..d5afe333ca9 100644 --- a/polaris-react/src/components/Frame/components/CSSAnimation/CSSAnimation.tsx +++ b/polaris-react/src/components/Frame/components/CSSAnimation/CSSAnimation.tsx @@ -1,4 +1,4 @@ -import React, {useRef, useState, useEffect} from 'react'; +import {useRef, useState, useEffect} from 'react'; import {classNames, variationName} from '../../../../utilities/css'; diff --git a/polaris-react/src/components/Frame/components/ContextualSaveBar/ContextualSaveBar.tsx b/polaris-react/src/components/Frame/components/ContextualSaveBar/ContextualSaveBar.tsx index a78dd7da196..8a188c93aa2 100644 --- a/polaris-react/src/components/Frame/components/ContextualSaveBar/ContextualSaveBar.tsx +++ b/polaris-react/src/components/Frame/components/ContextualSaveBar/ContextualSaveBar.tsx @@ -1,4 +1,4 @@ -import React, {useCallback} from 'react'; +import { useCallback } from 'react'; import {Button} from '../../../Button'; import {Image} from '../../../Image'; diff --git a/polaris-react/src/components/Frame/components/ContextualSaveBar/components/DiscardConfirmationModal/DiscardConfirmationModal.tsx b/polaris-react/src/components/Frame/components/ContextualSaveBar/components/DiscardConfirmationModal/DiscardConfirmationModal.tsx index 2fd5003d1cf..5c6e327d8ac 100644 --- a/polaris-react/src/components/Frame/components/ContextualSaveBar/components/DiscardConfirmationModal/DiscardConfirmationModal.tsx +++ b/polaris-react/src/components/Frame/components/ContextualSaveBar/components/DiscardConfirmationModal/DiscardConfirmationModal.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {useI18n} from '../../../../../../utilities/i18n'; import {Modal} from '../../../../../Modal'; diff --git a/polaris-react/src/components/Frame/components/ContextualSaveBar/components/DiscardConfirmationModal/tests/DiscardConfirmationModal.test.tsx b/polaris-react/src/components/Frame/components/ContextualSaveBar/components/DiscardConfirmationModal/tests/DiscardConfirmationModal.test.tsx index c8b60925d9e..5b4691d2ee9 100644 --- a/polaris-react/src/components/Frame/components/ContextualSaveBar/components/DiscardConfirmationModal/tests/DiscardConfirmationModal.test.tsx +++ b/polaris-react/src/components/Frame/components/ContextualSaveBar/components/DiscardConfirmationModal/tests/DiscardConfirmationModal.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Modal} from '../../../../../../Modal'; diff --git a/polaris-react/src/components/Frame/components/ContextualSaveBar/tests/ContextualSaveBar.test.tsx b/polaris-react/src/components/Frame/components/ContextualSaveBar/tests/ContextualSaveBar.test.tsx index 6f878e48a95..a9c52e1135e 100644 --- a/polaris-react/src/components/Frame/components/ContextualSaveBar/tests/ContextualSaveBar.test.tsx +++ b/polaris-react/src/components/Frame/components/ContextualSaveBar/tests/ContextualSaveBar.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Button} from '../../../../Button'; diff --git a/polaris-react/src/components/Frame/components/Loading/Loading.tsx b/polaris-react/src/components/Frame/components/Loading/Loading.tsx index 068a5c67d7b..c902df94fba 100644 --- a/polaris-react/src/components/Frame/components/Loading/Loading.tsx +++ b/polaris-react/src/components/Frame/components/Loading/Loading.tsx @@ -1,4 +1,4 @@ -import React, {useEffect, useState} from 'react'; +import { useEffect, useState } from 'react'; import {useI18n} from '../../../../utilities/i18n'; import {useIsMountedRef} from '../../../../utilities/use-is-mounted-ref'; diff --git a/polaris-react/src/components/Frame/components/Loading/tests/Loading.test.tsx b/polaris-react/src/components/Frame/components/Loading/tests/Loading.test.tsx index e841c08c704..12c0ef6a953 100644 --- a/polaris-react/src/components/Frame/components/Loading/tests/Loading.test.tsx +++ b/polaris-react/src/components/Frame/components/Loading/tests/Loading.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Loading} from '../Loading'; diff --git a/polaris-react/src/components/Frame/components/Toast/Toast.tsx b/polaris-react/src/components/Frame/components/Toast/Toast.tsx index 106f9284ddf..b068a4e35e5 100644 --- a/polaris-react/src/components/Frame/components/Toast/Toast.tsx +++ b/polaris-react/src/components/Frame/components/Toast/Toast.tsx @@ -1,4 +1,4 @@ -import React, {useEffect} from 'react'; +import { useEffect } from 'react'; import {CancelSmallMinor, AlertMinor} from '@shopify/polaris-icons'; import {classNames} from '../../../../utilities/css'; diff --git a/polaris-react/src/components/Frame/components/Toast/tests/Toast.test.tsx b/polaris-react/src/components/Frame/components/Toast/tests/Toast.test.tsx index c8aefb19387..19b61470f5e 100644 --- a/polaris-react/src/components/Frame/components/Toast/tests/Toast.test.tsx +++ b/polaris-react/src/components/Frame/components/Toast/tests/Toast.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {timer} from '@shopify/jest-dom-mocks'; import {mountWithApp} from 'tests/utilities'; diff --git a/polaris-react/src/components/Frame/components/ToastManager/ToastManager.tsx b/polaris-react/src/components/Frame/components/ToastManager/ToastManager.tsx index 6cd3f20efd6..662e664b4eb 100644 --- a/polaris-react/src/components/Frame/components/ToastManager/ToastManager.tsx +++ b/polaris-react/src/components/Frame/components/ToastManager/ToastManager.tsx @@ -1,4 +1,4 @@ -import React, {createRef, memo} from 'react'; +import {createRef, memo} from 'react'; import {TransitionGroup, CSSTransition} from 'react-transition-group'; import {classNames} from '../../../../utilities/css'; diff --git a/polaris-react/src/components/Frame/components/ToastManager/tests/ToastManager.test.tsx b/polaris-react/src/components/Frame/components/ToastManager/tests/ToastManager.test.tsx index 37d1e411e61..afbc03ff2f7 100644 --- a/polaris-react/src/components/Frame/components/ToastManager/tests/ToastManager.test.tsx +++ b/polaris-react/src/components/Frame/components/ToastManager/tests/ToastManager.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {timer} from '@shopify/jest-dom-mocks'; import {mountWithApp} from 'tests/utilities'; diff --git a/polaris-react/src/components/Frame/tests/Frame.test.tsx b/polaris-react/src/components/Frame/tests/Frame.test.tsx index f417676188b..bb74a127125 100644 --- a/polaris-react/src/components/Frame/tests/Frame.test.tsx +++ b/polaris-react/src/components/Frame/tests/Frame.test.tsx @@ -1,4 +1,4 @@ -import React, {createRef} from 'react'; +import { createRef } from 'react'; import {CSSTransition} from 'react-transition-group'; import {animationFrame, dimension} from '@shopify/jest-dom-mocks'; import {mountWithApp} from 'tests/utilities'; diff --git a/polaris-react/src/components/FullscreenBar/FullscreenBar.stories.tsx b/polaris-react/src/components/FullscreenBar/FullscreenBar.stories.tsx index 4d386ffb777..1882e39a13d 100644 --- a/polaris-react/src/components/FullscreenBar/FullscreenBar.stories.tsx +++ b/polaris-react/src/components/FullscreenBar/FullscreenBar.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useState} from 'react'; +import { useCallback, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import { Badge, diff --git a/polaris-react/src/components/FullscreenBar/FullscreenBar.tsx b/polaris-react/src/components/FullscreenBar/FullscreenBar.tsx index 6982d57c725..6741c222431 100644 --- a/polaris-react/src/components/FullscreenBar/FullscreenBar.tsx +++ b/polaris-react/src/components/FullscreenBar/FullscreenBar.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {ExitMajor} from '@shopify/polaris-icons'; import {Icon} from '../Icon'; diff --git a/polaris-react/src/components/FullscreenBar/tests/FullscreenBar.test.tsx b/polaris-react/src/components/FullscreenBar/tests/FullscreenBar.test.tsx index ce43bd92f60..3c986f4f9a9 100644 --- a/polaris-react/src/components/FullscreenBar/tests/FullscreenBar.test.tsx +++ b/polaris-react/src/components/FullscreenBar/tests/FullscreenBar.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {FullscreenBar} from '../FullscreenBar'; diff --git a/polaris-react/src/components/Grid/Grid.stories.tsx b/polaris-react/src/components/Grid/Grid.stories.tsx index 055385e612d..7835afe91c4 100644 --- a/polaris-react/src/components/Grid/Grid.stories.tsx +++ b/polaris-react/src/components/Grid/Grid.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import {LegacyCard, Grid, Page} from '@shopify/polaris'; diff --git a/polaris-react/src/components/Grid/Grid.tsx b/polaris-react/src/components/Grid/Grid.tsx index 2dcb24f3ee9..744331a99cd 100644 --- a/polaris-react/src/components/Grid/Grid.tsx +++ b/polaris-react/src/components/Grid/Grid.tsx @@ -1,4 +1,4 @@ -import React, {useEffect} from 'react'; +import {useEffect} from 'react'; // eslint-disable-next-line import/no-deprecated import {Cell} from './components'; @@ -27,7 +27,7 @@ export interface GridProps { gap?: Gap; children?: React.ReactNode; } -/** @deprecated Use `Columns` instead or a combination of layout primitives (`Columns`, `Inline`, and `AlphaStack`) */ +/** @deprecated Use `Columns` instead or a combination of layout primitives (`Columns`, `Inline`, and `Stack`) */ export const Grid: React.FunctionComponent & { // eslint-disable-next-line import/no-deprecated Cell: typeof Cell; @@ -54,7 +54,7 @@ export const Grid: React.FunctionComponent & { if (process.env.NODE_ENV === 'development') { // eslint-disable-next-line no-console console.warn( - 'Deprecation: is deprecated. This component will be removed in a future major version of Polaris. Use instead or a combination of , , and ', + 'Deprecation: is deprecated. This component will be removed in a future major version of Polaris. Use instead or a combination of , , and ', ); } }, []); diff --git a/polaris-react/src/components/Grid/components/Cell/Cell.tsx b/polaris-react/src/components/Grid/components/Cell/Cell.tsx index 35882f8e3ee..fa5398e36a1 100644 --- a/polaris-react/src/components/Grid/components/Cell/Cell.tsx +++ b/polaris-react/src/components/Grid/components/Cell/Cell.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {classNames} from '../../../../utilities/css'; import styles from './Cell.scss'; @@ -30,7 +28,7 @@ export interface CellProps { row?: Cell; children?: React.ReactNode; } -/** @deprecated Use `Columns` instead or a combination of layout primitives (`Columns`, `Inline`, and `AlphaStack`) */ +/** @deprecated Use `Columns` instead or a combination of layout primitives (`Columns`, `Inline`, and `Stack`) */ export function Cell({ area: gridArea, column, diff --git a/polaris-react/src/components/Grid/components/Cell/tests/Cell.test.tsx b/polaris-react/src/components/Grid/components/Cell/tests/Cell.test.tsx index 3f05de04cce..82d2054e061 100644 --- a/polaris-react/src/components/Grid/components/Cell/tests/Cell.test.tsx +++ b/polaris-react/src/components/Grid/components/Cell/tests/Cell.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; // eslint-disable-next-line import/no-deprecated diff --git a/polaris-react/src/components/Grid/tests/Grid.test.tsx b/polaris-react/src/components/Grid/tests/Grid.test.tsx index 0b27b4ec222..6ac5cbd6775 100644 --- a/polaris-react/src/components/Grid/tests/Grid.test.tsx +++ b/polaris-react/src/components/Grid/tests/Grid.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {matchMedia, timer} from '@shopify/jest-dom-mocks'; import {mountWithApp} from 'tests/utilities'; diff --git a/polaris-react/src/components/Heading/Heading.scss b/polaris-react/src/components/Heading/Heading.scss deleted file mode 100644 index 41f0e282378..00000000000 --- a/polaris-react/src/components/Heading/Heading.scss +++ /dev/null @@ -1,12 +0,0 @@ -@import '../../styles/common'; - -.Heading { - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - @include text-style-heading; - margin: 0; - - @media print { - font-size: var(--p-font-size-100); - line-height: var(--p-font-line-height-1); - } -} diff --git a/polaris-react/src/components/Heading/Heading.stories.tsx b/polaris-react/src/components/Heading/Heading.stories.tsx deleted file mode 100644 index b6b6753d554..00000000000 --- a/polaris-react/src/components/Heading/Heading.stories.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import React from 'react'; -import type {ComponentMeta} from '@storybook/react'; -import {Heading} from '@shopify/polaris'; - -export default { - component: Heading, -} as ComponentMeta; - -export function Default() { - return Online store dashboard; -} diff --git a/polaris-react/src/components/Heading/Heading.tsx b/polaris-react/src/components/Heading/Heading.tsx deleted file mode 100644 index e1fbb916d12..00000000000 --- a/polaris-react/src/components/Heading/Heading.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import React from 'react'; - -import type {HeadingTagName} from '../../types'; - -import styles from './Heading.scss'; - -export interface HeadingProps { - /** - * The element name to use for the heading - * @default 'h2' - */ - element?: HeadingTagName; - /** The content to display inside the heading */ - children?: React.ReactNode; - /** A unique identifier for the heading, used for reference in anchor links */ - id?: string; -} - -/** - * @deprecated The Heading component will be removed in the next - * major version. Use the Text component instead. See the - * Polaris component guide on how to use Text. - * - * https://polaris.shopify.com/components/text - */ -export function Heading({element: Element = 'h2', children, id}: HeadingProps) { - return ( - - {children} - - ); -} diff --git a/polaris-react/src/components/Heading/index.ts b/polaris-react/src/components/Heading/index.ts deleted file mode 100644 index 6406e7b07f4..00000000000 --- a/polaris-react/src/components/Heading/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Heading'; diff --git a/polaris-react/src/components/Heading/tests/Heading.test.tsx b/polaris-react/src/components/Heading/tests/Heading.test.tsx deleted file mode 100644 index e4851751985..00000000000 --- a/polaris-react/src/components/Heading/tests/Heading.test.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import React from 'react'; -import {mountWithApp} from 'tests/utilities'; - -// eslint-disable-next-line import/no-deprecated -import {Heading} from '../Heading'; - -describe('', () => { - it('renders its children', () => { - const text = 'Online store dashboard'; - const heading = mountWithApp({text}); - expect(heading).toContainReactText(text); - }); - - it('renders the specified element', () => { - const heading = mountWithApp( - Online store dashboard, - ); - expect(heading.find('h1')).not.toBeNull(); - }); - - it('renders an h2 element if not specified', () => { - const heading = mountWithApp(Online store dashboard); - expect(heading.find('h2')).not.toBeNull(); - }); - - it('renders an ID for hash links', () => { - const heading = mountWithApp( - - Online store dashboard - , - ); - expect(heading.find('h1')!.props.id).toBe('dashboard'); - }); -}); diff --git a/polaris-react/src/components/Icon/Icon.stories.tsx b/polaris-react/src/components/Icon/Icon.stories.tsx index f72c5e1f4eb..e6c65c67e14 100644 --- a/polaris-react/src/components/Icon/Icon.stories.tsx +++ b/polaris-react/src/components/Icon/Icon.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import {Icon} from '@shopify/polaris'; import {CirclePlusMinor} from '@shopify/polaris-icons'; diff --git a/polaris-react/src/components/Icon/Icon.tsx b/polaris-react/src/components/Icon/Icon.tsx index ebf16b5172a..ceec2968d64 100644 --- a/polaris-react/src/components/Icon/Icon.tsx +++ b/polaris-react/src/components/Icon/Icon.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {Text} from '../Text'; import {classNames, variationName} from '../../utilities/css'; import type {IconSource} from '../../types'; diff --git a/polaris-react/src/components/Icon/tests/Icon.test.tsx b/polaris-react/src/components/Icon/tests/Icon.test.tsx index 36837a7d227..63fafcde837 100644 --- a/polaris-react/src/components/Icon/tests/Icon.test.tsx +++ b/polaris-react/src/components/Icon/tests/Icon.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {PlusMinor} from '@shopify/polaris-icons'; import {mountWithApp} from 'tests/utilities'; diff --git a/polaris-react/src/components/Image/Image.tsx b/polaris-react/src/components/Image/Image.tsx index 8b2657fbbfe..9216d890d0f 100644 --- a/polaris-react/src/components/Image/Image.tsx +++ b/polaris-react/src/components/Image/Image.tsx @@ -1,4 +1,4 @@ -import React, {useCallback} from 'react'; +import {useCallback} from 'react'; interface SourceSet { source: string; diff --git a/polaris-react/src/components/Image/tests/Image.test.tsx b/polaris-react/src/components/Image/tests/Image.test.tsx index 475ca8fb2bc..b280cd0c280 100644 --- a/polaris-react/src/components/Image/tests/Image.test.tsx +++ b/polaris-react/src/components/Image/tests/Image.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Image} from '../Image'; diff --git a/polaris-react/src/components/IndexProvider/IndexProvider.tsx b/polaris-react/src/components/IndexProvider/IndexProvider.tsx index 37ab5321ce9..78bdca3ea21 100644 --- a/polaris-react/src/components/IndexProvider/IndexProvider.tsx +++ b/polaris-react/src/components/IndexProvider/IndexProvider.tsx @@ -1,4 +1,4 @@ -import React, {useMemo} from 'react'; +import { useMemo } from 'react'; import { IndexContext, diff --git a/polaris-react/src/components/IndexProvider/tests/IndexProvider.test.tsx b/polaris-react/src/components/IndexProvider/tests/IndexProvider.test.tsx index 6c2cb9781ca..4ed34fa5cf7 100644 --- a/polaris-react/src/components/IndexProvider/tests/IndexProvider.test.tsx +++ b/polaris-react/src/components/IndexProvider/tests/IndexProvider.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {IndexProvider} from '../IndexProvider'; diff --git a/polaris-react/src/components/IndexTable/IndexTable.stories.tsx b/polaris-react/src/components/IndexTable/IndexTable.stories.tsx index 933e12086bf..eeaad6a39c0 100644 --- a/polaris-react/src/components/IndexTable/IndexTable.stories.tsx +++ b/polaris-react/src/components/IndexTable/IndexTable.stories.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useState} from 'react'; +import { useCallback, useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import { Button, diff --git a/polaris-react/src/components/IndexTable/IndexTable.tsx b/polaris-react/src/components/IndexTable/IndexTable.tsx index e9c2d5d259e..3e3c0039c5d 100644 --- a/polaris-react/src/components/IndexTable/IndexTable.tsx +++ b/polaris-react/src/components/IndexTable/IndexTable.tsx @@ -1,4 +1,4 @@ -import React, {useRef, useState, useEffect, useCallback, useMemo} from 'react'; +import {useRef, useState, useEffect, useCallback, useMemo} from 'react'; import {SortAscendingMajor, SortDescendingMajor} from '@shopify/polaris-icons'; import {CSSTransition} from 'react-transition-group'; import {tokens, toPx, motion} from '@shopify/polaris-tokens'; diff --git a/polaris-react/src/components/IndexTable/components/Cell/Cell.tsx b/polaris-react/src/components/IndexTable/components/Cell/Cell.tsx index a3ebf8bd0c5..e0512ccdc91 100644 --- a/polaris-react/src/components/IndexTable/components/Cell/Cell.tsx +++ b/polaris-react/src/components/IndexTable/components/Cell/Cell.tsx @@ -1,4 +1,4 @@ -import React, {memo, ReactNode} from 'react'; +import { memo, ReactNode } from 'react'; import {classNames} from '../../../../utilities/css'; import styles from '../../IndexTable.scss'; diff --git a/polaris-react/src/components/IndexTable/components/Cell/tests/Cell.test.tsx b/polaris-react/src/components/IndexTable/components/Cell/tests/Cell.test.tsx index 32d420ebfa3..2d44163e30a 100644 --- a/polaris-react/src/components/IndexTable/components/Cell/tests/Cell.test.tsx +++ b/polaris-react/src/components/IndexTable/components/Cell/tests/Cell.test.tsx @@ -1,4 +1,4 @@ -import React, {ReactElement} from 'react'; +import { ReactElement } from 'react'; import {mountWithApp} from 'tests/utilities'; import {Cell} from '../Cell'; diff --git a/polaris-react/src/components/IndexTable/components/Checkbox/Checkbox.tsx b/polaris-react/src/components/IndexTable/components/Checkbox/Checkbox.tsx index d332b0921a9..50159945fac 100644 --- a/polaris-react/src/components/IndexTable/components/Checkbox/Checkbox.tsx +++ b/polaris-react/src/components/IndexTable/components/Checkbox/Checkbox.tsx @@ -1,12 +1,4 @@ -import React, { - useContext, - memo, - useEffect, - useRef, - useCallback, - Fragment, - ReactNode, -} from 'react'; +import { useContext, memo, useEffect, useRef, useCallback, Fragment, ReactNode } from 'react'; import {debounce} from '../../../../utilities/debounce'; import {useI18n} from '../../../../utilities/i18n'; diff --git a/polaris-react/src/components/IndexTable/components/Checkbox/tests/Checkbox.test.tsx b/polaris-react/src/components/IndexTable/components/Checkbox/tests/Checkbox.test.tsx index 9c4d853732a..aac069bea94 100644 --- a/polaris-react/src/components/IndexTable/components/Checkbox/tests/Checkbox.test.tsx +++ b/polaris-react/src/components/IndexTable/components/Checkbox/tests/Checkbox.test.tsx @@ -1,4 +1,4 @@ -import React, {ReactElement} from 'react'; +import { ReactElement } from 'react'; import {mountWithApp} from 'tests/utilities'; import type {Element as ElementType} from '@shopify/react-testing'; import {act} from 'react-dom/test-utils'; diff --git a/polaris-react/src/components/IndexTable/components/Row/Row.tsx b/polaris-react/src/components/IndexTable/components/Row/Row.tsx index c97795fb1f9..cb18c346809 100644 --- a/polaris-react/src/components/IndexTable/components/Row/Row.tsx +++ b/polaris-react/src/components/IndexTable/components/Row/Row.tsx @@ -1,4 +1,4 @@ -import React, {useMemo, memo, useRef, useCallback} from 'react'; +import {useMemo, memo, useRef, useCallback} from 'react'; import {useToggle} from '../../../../utilities/use-toggle'; import { diff --git a/polaris-react/src/components/IndexTable/components/Row/tests/Row.test.tsx b/polaris-react/src/components/IndexTable/components/Row/tests/Row.test.tsx index a9ac9e5c98b..bcff0eccca1 100644 --- a/polaris-react/src/components/IndexTable/components/Row/tests/Row.test.tsx +++ b/polaris-react/src/components/IndexTable/components/Row/tests/Row.test.tsx @@ -1,4 +1,4 @@ -import React, {ReactElement} from 'react'; +import {ReactElement} from 'react'; import {mountWithApp} from 'tests/utilities'; import type {DeepPartial} from '@shopify/useful-types'; diff --git a/polaris-react/src/components/IndexTable/components/ScrollContainer/ScrollContainer.tsx b/polaris-react/src/components/IndexTable/components/ScrollContainer/ScrollContainer.tsx index 04d02e079a1..78299a5782f 100644 --- a/polaris-react/src/components/IndexTable/components/ScrollContainer/ScrollContainer.tsx +++ b/polaris-react/src/components/IndexTable/components/ScrollContainer/ScrollContainer.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useEffect, useState} from 'react'; +import {useCallback, useEffect, useState} from 'react'; import {debounce} from '../../../../utilities/debounce'; import { diff --git a/polaris-react/src/components/IndexTable/components/ScrollContainer/tests/ScrollContainer.test.tsx b/polaris-react/src/components/IndexTable/components/ScrollContainer/tests/ScrollContainer.test.tsx index c17635bd683..c44587d54b3 100644 --- a/polaris-react/src/components/IndexTable/components/ScrollContainer/tests/ScrollContainer.test.tsx +++ b/polaris-react/src/components/IndexTable/components/ScrollContainer/tests/ScrollContainer.test.tsx @@ -1,18 +1,18 @@ -import React from 'react'; +import { useRef, createRef } from 'react'; import {mountWithApp} from 'tests/utilities'; import {ScrollContext} from '../../../../../utilities/index-table'; import {ScrollContainer} from '../ScrollContainer'; function TestComponent() { - const containerRef = React.useRef(null); + const containerRef = useRef(null); return
Hello
; } describe('', () => { it('renders a ScrollContext provider', () => { - const ref = React.createRef(); + const ref = createRef(); const wrapper = mountWithApp( {}}> diff --git a/polaris-react/src/components/IndexTable/tests/IndexTable.test.tsx b/polaris-react/src/components/IndexTable/tests/IndexTable.test.tsx index bfe15186e2d..6818bcf68f3 100644 --- a/polaris-react/src/components/IndexTable/tests/IndexTable.test.tsx +++ b/polaris-react/src/components/IndexTable/tests/IndexTable.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {SortAscendingMajor, SortDescendingMajor} from '@shopify/polaris-icons'; diff --git a/polaris-react/src/components/Indicator/Indicator.tsx b/polaris-react/src/components/Indicator/Indicator.tsx index 47c770ed476..a774af2c4a8 100644 --- a/polaris-react/src/components/Indicator/Indicator.tsx +++ b/polaris-react/src/components/Indicator/Indicator.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {classNames} from '../../utilities/css'; import styles from './Indicator.scss'; diff --git a/polaris-react/src/components/Indicator/tests/Indicator.test.tsx b/polaris-react/src/components/Indicator/tests/Indicator.test.tsx index 9581b7411ce..7424b93b7bc 100644 --- a/polaris-react/src/components/Indicator/tests/Indicator.test.tsx +++ b/polaris-react/src/components/Indicator/tests/Indicator.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Indicator} from '../Indicator'; diff --git a/polaris-react/src/components/Inline/Inline.stories.tsx b/polaris-react/src/components/Inline/Inline.stories.tsx index bf0dee3d02d..9369a8ee860 100644 --- a/polaris-react/src/components/Inline/Inline.stories.tsx +++ b/polaris-react/src/components/Inline/Inline.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import {Box, Badge, Icon, Inline, Thumbnail} from '@shopify/polaris'; import {CapitalMajor, ImageMajor} from '@shopify/polaris-icons'; diff --git a/polaris-react/src/components/Inline/Inline.tsx b/polaris-react/src/components/Inline/Inline.tsx index 0ce91aec553..9eb40ec018d 100644 --- a/polaris-react/src/components/Inline/Inline.tsx +++ b/polaris-react/src/components/Inline/Inline.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {SpacingSpaceScale} from '@shopify/polaris-tokens'; import {getResponsiveProps} from '../../utilities/css'; diff --git a/polaris-react/src/components/Inline/tests/Inline.test.tsx b/polaris-react/src/components/Inline/tests/Inline.test.tsx index d110fc419e4..59cfe92c29a 100644 --- a/polaris-react/src/components/Inline/tests/Inline.test.tsx +++ b/polaris-react/src/components/Inline/tests/Inline.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Inline} from '../Inline'; diff --git a/polaris-react/src/components/InlineCode/InlineCode.tsx b/polaris-react/src/components/InlineCode/InlineCode.tsx index 8f732347a90..9cafbf4bcd0 100644 --- a/polaris-react/src/components/InlineCode/InlineCode.tsx +++ b/polaris-react/src/components/InlineCode/InlineCode.tsx @@ -1,4 +1,4 @@ -import React, {ReactNode} from 'react'; +import { ReactNode } from 'react'; import styles from './InlineCode.scss'; diff --git a/polaris-react/src/components/InlineCode/tests/InlineCode.test.tsx b/polaris-react/src/components/InlineCode/tests/InlineCode.test.tsx index b05714416e4..a87d23d111a 100644 --- a/polaris-react/src/components/InlineCode/tests/InlineCode.test.tsx +++ b/polaris-react/src/components/InlineCode/tests/InlineCode.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {InlineCode} from '../InlineCode'; diff --git a/polaris-react/src/components/InlineError/InlineError.stories.tsx b/polaris-react/src/components/InlineError/InlineError.stories.tsx index 879db4bfb38..d43b6b325f2 100644 --- a/polaris-react/src/components/InlineError/InlineError.stories.tsx +++ b/polaris-react/src/components/InlineError/InlineError.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import {InlineError} from '@shopify/polaris'; diff --git a/polaris-react/src/components/InlineError/InlineError.tsx b/polaris-react/src/components/InlineError/InlineError.tsx index af0a40bf0d6..548219efa1a 100644 --- a/polaris-react/src/components/InlineError/InlineError.tsx +++ b/polaris-react/src/components/InlineError/InlineError.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {AlertMinor} from '@shopify/polaris-icons'; import {Icon} from '../Icon'; diff --git a/polaris-react/src/components/InlineError/tests/InlineError.test.tsx b/polaris-react/src/components/InlineError/tests/InlineError.test.tsx index 5a37f921e13..e7a205aa2cc 100644 --- a/polaris-react/src/components/InlineError/tests/InlineError.test.tsx +++ b/polaris-react/src/components/InlineError/tests/InlineError.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {InlineError, errorTextID} from '../InlineError'; diff --git a/polaris-react/src/components/KeyboardKey/KeyboardKey.stories.tsx b/polaris-react/src/components/KeyboardKey/KeyboardKey.stories.tsx index d695369eb40..a2a9379bf2d 100644 --- a/polaris-react/src/components/KeyboardKey/KeyboardKey.stories.tsx +++ b/polaris-react/src/components/KeyboardKey/KeyboardKey.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import {KeyboardKey} from '@shopify/polaris'; diff --git a/polaris-react/src/components/KeyboardKey/KeyboardKey.tsx b/polaris-react/src/components/KeyboardKey/KeyboardKey.tsx index 48143dde832..0a24c0b024c 100644 --- a/polaris-react/src/components/KeyboardKey/KeyboardKey.tsx +++ b/polaris-react/src/components/KeyboardKey/KeyboardKey.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {classNames} from '../../utilities/css'; import styles from './KeyboardKey.scss'; diff --git a/polaris-react/src/components/KeyboardKey/tests/KeyboardKey.test.tsx b/polaris-react/src/components/KeyboardKey/tests/KeyboardKey.test.tsx index 3089336e782..9cbef9e6156 100644 --- a/polaris-react/src/components/KeyboardKey/tests/KeyboardKey.test.tsx +++ b/polaris-react/src/components/KeyboardKey/tests/KeyboardKey.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {KeyboardKey} from '../KeyboardKey'; diff --git a/polaris-react/src/components/KeypressListener/tests/KeypressListener.test.tsx b/polaris-react/src/components/KeypressListener/tests/KeypressListener.test.tsx index d759e60f0e4..472661a3dc8 100644 --- a/polaris-react/src/components/KeypressListener/tests/KeypressListener.test.tsx +++ b/polaris-react/src/components/KeypressListener/tests/KeypressListener.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Key} from '../../../types'; diff --git a/polaris-react/src/components/KonamiCode/KonamiCode.tsx b/polaris-react/src/components/KonamiCode/KonamiCode.tsx deleted file mode 100644 index 93ade688a32..00000000000 --- a/polaris-react/src/components/KonamiCode/KonamiCode.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import {useEffect, useRef} from 'react'; - -import {Key} from '../../types'; - -export interface KonamiCodeProps { - handler(event: KeyboardEvent): void; -} - -export const KONAMI_CODE = [ - Key.UpArrow, - Key.UpArrow, - Key.DownArrow, - Key.DownArrow, - Key.LeftArrow, - Key.RightArrow, - Key.LeftArrow, - Key.RightArrow, - Key.KeyB, - Key.KeyA, -]; - -export function KonamiCode({handler}: KonamiCodeProps) { - const keyEvent = 'keydown'; - const position = useRef(0); - - const handleKeyEvent = (event: KeyboardEvent) => { - const key = event.keyCode; - const requiredKey = KONAMI_CODE[position.current]; - - if (key === requiredKey) { - if (position.current === KONAMI_CODE.length - 1) { - handler(event); - position.current = 0; - } else { - position.current++; - } - } else { - position.current = 0; - } - }; - - useEffect(() => { - document.addEventListener(keyEvent, handleKeyEvent); - return () => { - document.removeEventListener(keyEvent, handleKeyEvent); - }; - }); - - return null; -} diff --git a/polaris-react/src/components/KonamiCode/index.ts b/polaris-react/src/components/KonamiCode/index.ts deleted file mode 100644 index bcbf369993a..00000000000 --- a/polaris-react/src/components/KonamiCode/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './KonamiCode'; diff --git a/polaris-react/src/components/KonamiCode/tests/KonamiCode.test.tsx b/polaris-react/src/components/KonamiCode/tests/KonamiCode.test.tsx deleted file mode 100644 index 7e848454861..00000000000 --- a/polaris-react/src/components/KonamiCode/tests/KonamiCode.test.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import React from 'react'; -import {mountWithApp} from 'tests/utilities'; - -import {KonamiCode, KONAMI_CODE} from '../KonamiCode'; - -describe('', () => { - beforeEach(() => { - jest.spyOn(console, 'error').mockImplementation(); - }); - - afterEach(() => { - // eslint-disable-next-line no-console - (console.error as jest.Mock).mockRestore(); - }); - - it('calls the handler when the Konami Code is entered', () => { - const spy = jest.fn(); - - mountWithApp(); - simulateKeySequence(KONAMI_CODE); - - expect(spy).toHaveBeenCalledTimes(1); - }); - - it('does not call the handler if the code is wrong', () => { - const spy = jest.fn(); - const reverseKonamiCode = [...KONAMI_CODE].reverse(); - - mountWithApp(); - simulateKeySequence(reverseKonamiCode); - - expect(spy).toHaveBeenCalledTimes(0); - }); - - it('removes Konami Code listener on unmount', () => { - const spy = jest.fn(); - - mountWithApp().unmount(); - simulateKeySequence(KONAMI_CODE); - - expect(spy).toHaveBeenCalledTimes(0); - }); -}); - -function simulateKeySequence(keys: number[]) { - for (const keyCode of keys) { - dispatchKeydown(keyCode); - } -} - -function dispatchKeydown(keyCode: number) { - const event: KeyboardEventInit & {keyCode: number} = {keyCode}; - document.dispatchEvent(new KeyboardEvent('keydown', event)); -} diff --git a/polaris-react/src/components/Label/Label.tsx b/polaris-react/src/components/Label/Label.tsx index 04a8c746d18..22e37952d29 100644 --- a/polaris-react/src/components/Label/Label.tsx +++ b/polaris-react/src/components/Label/Label.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {classNames} from '../../utilities/css'; import styles from './Label.scss'; diff --git a/polaris-react/src/components/Label/tests/Label.test.tsx b/polaris-react/src/components/Label/tests/Label.test.tsx index 2b6acb04b76..f7df7eb3113 100644 --- a/polaris-react/src/components/Label/tests/Label.test.tsx +++ b/polaris-react/src/components/Label/tests/Label.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Label, labelID} from '../Label'; diff --git a/polaris-react/src/components/Labelled/Labelled.tsx b/polaris-react/src/components/Labelled/Labelled.tsx index e4a07e65b79..67efaf9fe1d 100644 --- a/polaris-react/src/components/Labelled/Labelled.tsx +++ b/polaris-react/src/components/Labelled/Labelled.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {classNames} from '../../utilities/css'; import type {Action, Error} from '../../types'; import {buttonFrom} from '../Button'; diff --git a/polaris-react/src/components/Labelled/tests/Labelled.test.tsx b/polaris-react/src/components/Labelled/tests/Labelled.test.tsx index e4d28273bef..d8704895bf1 100644 --- a/polaris-react/src/components/Labelled/tests/Labelled.test.tsx +++ b/polaris-react/src/components/Labelled/tests/Labelled.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Button} from '../../Button'; diff --git a/polaris-react/src/components/Layout/Layout.stories.tsx b/polaris-react/src/components/Layout/Layout.stories.tsx index 87dd41a6381..db866f82d20 100644 --- a/polaris-react/src/components/Layout/Layout.stories.tsx +++ b/polaris-react/src/components/Layout/Layout.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import { Banner, diff --git a/polaris-react/src/components/Layout/Layout.tsx b/polaris-react/src/components/Layout/Layout.tsx index fad85a4eb10..fced30b6804 100644 --- a/polaris-react/src/components/Layout/Layout.tsx +++ b/polaris-react/src/components/Layout/Layout.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {AnnotatedSection, Section} from './components'; import styles from './Layout.scss'; diff --git a/polaris-react/src/components/Layout/components/AnnotatedSection/AnnotatedSection.tsx b/polaris-react/src/components/Layout/components/AnnotatedSection/AnnotatedSection.tsx index bac092e7afe..03817f62bb5 100644 --- a/polaris-react/src/components/Layout/components/AnnotatedSection/AnnotatedSection.tsx +++ b/polaris-react/src/components/Layout/components/AnnotatedSection/AnnotatedSection.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {Box} from '../../../Box'; import {Text} from '../../../Text'; // eslint-disable-next-line import/no-deprecated diff --git a/polaris-react/src/components/Layout/components/Section/Section.tsx b/polaris-react/src/components/Layout/components/Section/Section.tsx index 628ee1628ec..6a00b2562e4 100644 --- a/polaris-react/src/components/Layout/components/Section/Section.tsx +++ b/polaris-react/src/components/Layout/components/Section/Section.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {classNames} from '../../../../utilities/css'; import styles from '../../Layout.scss'; diff --git a/polaris-react/src/components/Layout/tests/Layout.test.tsx b/polaris-react/src/components/Layout/tests/Layout.test.tsx index 4bb114ed4a1..c7fbaf0d532 100644 --- a/polaris-react/src/components/Layout/tests/Layout.test.tsx +++ b/polaris-react/src/components/Layout/tests/Layout.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Text} from '../../Text'; diff --git a/polaris-react/src/components/LegacyCard/LegacyCard.scss b/polaris-react/src/components/LegacyCard/LegacyCard.scss index 1e8f2d3945f..b913e201617 100644 --- a/polaris-react/src/components/LegacyCard/LegacyCard.scss +++ b/polaris-react/src/components/LegacyCard/LegacyCard.scss @@ -12,14 +12,6 @@ margin-top: calc(-1 * var(--p-space-2)); } } - /* stylelint-disable-next-line polaris/conventions/selector-disallowed-list -- Temporary override, will be removed in v11 */ - + [class^='Polaris-Card'] { - margin-top: var(--p-space-4); - - @media print { - margin-top: calc(-1 * var(--p-space-2)); - } - } @media #{$p-breakpoints-sm-up} { border-radius: var(--p-border-radius-2); diff --git a/polaris-react/src/components/LegacyCard/LegacyCard.stories.tsx b/polaris-react/src/components/LegacyCard/LegacyCard.stories.tsx index 4663bce56b9..f5c1d9005f2 100644 --- a/polaris-react/src/components/LegacyCard/LegacyCard.stories.tsx +++ b/polaris-react/src/components/LegacyCard/LegacyCard.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import { ActionList, diff --git a/polaris-react/src/components/LegacyCard/LegacyCard.tsx b/polaris-react/src/components/LegacyCard/LegacyCard.tsx index 1901c90ccaa..990974c9126 100644 --- a/polaris-react/src/components/LegacyCard/LegacyCard.tsx +++ b/polaris-react/src/components/LegacyCard/LegacyCard.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {useI18n} from '../../utilities/i18n'; import {classNames} from '../../utilities/css'; import {useToggle} from '../../utilities/use-toggle'; diff --git a/polaris-react/src/components/LegacyCard/components/Header/Header.tsx b/polaris-react/src/components/LegacyCard/components/Header/Header.tsx index 617da8cf88e..85fb5c715ec 100644 --- a/polaris-react/src/components/LegacyCard/components/Header/Header.tsx +++ b/polaris-react/src/components/LegacyCard/components/Header/Header.tsx @@ -1,4 +1,4 @@ -import React, {isValidElement} from 'react'; +import {isValidElement} from 'react'; import type {DisableableAction} from '../../../../types'; import {buttonsFrom} from '../../../Button'; diff --git a/polaris-react/src/components/LegacyCard/components/Header/tests/Header.test.tsx b/polaris-react/src/components/LegacyCard/components/Header/tests/Header.test.tsx index 6449674f507..5e9717a56fc 100644 --- a/polaris-react/src/components/LegacyCard/components/Header/tests/Header.test.tsx +++ b/polaris-react/src/components/LegacyCard/components/Header/tests/Header.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {buttonsFrom} from '../../../../Button'; diff --git a/polaris-react/src/components/LegacyCard/components/Section/Section.tsx b/polaris-react/src/components/LegacyCard/components/Section/Section.tsx index 0e9f7fa68ce..b7a697b90b1 100644 --- a/polaris-react/src/components/LegacyCard/components/Section/Section.tsx +++ b/polaris-react/src/components/LegacyCard/components/Section/Section.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {classNames} from '../../../../utilities/css'; import type {ComplexAction} from '../../../../types'; import {buttonsFrom} from '../../../Button'; diff --git a/polaris-react/src/components/LegacyCard/components/Section/tests/Section.test.tsx b/polaris-react/src/components/LegacyCard/components/Section/tests/Section.test.tsx index be63f7cdfdd..f6024b117a1 100644 --- a/polaris-react/src/components/LegacyCard/components/Section/tests/Section.test.tsx +++ b/polaris-react/src/components/LegacyCard/components/Section/tests/Section.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Badge} from '../../../../Badge'; diff --git a/polaris-react/src/components/LegacyCard/components/Subsection/Subsection.tsx b/polaris-react/src/components/LegacyCard/components/Subsection/Subsection.tsx index c72f6b5ef35..f306f4f57af 100644 --- a/polaris-react/src/components/LegacyCard/components/Subsection/Subsection.tsx +++ b/polaris-react/src/components/LegacyCard/components/Subsection/Subsection.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import styles from '../../LegacyCard.scss'; export interface LegacyCardSubsectionProps { diff --git a/polaris-react/src/components/LegacyCard/components/Subsection/tests/Subsection.test.tsx b/polaris-react/src/components/LegacyCard/components/Subsection/tests/Subsection.test.tsx index 0aaeea43fe2..5a7c2a035e5 100644 --- a/polaris-react/src/components/LegacyCard/components/Subsection/tests/Subsection.test.tsx +++ b/polaris-react/src/components/LegacyCard/components/Subsection/tests/Subsection.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Subsection} from '../Subsection'; diff --git a/polaris-react/src/components/LegacyCard/tests/LegacyCard.test.tsx b/polaris-react/src/components/LegacyCard/tests/LegacyCard.test.tsx index e923f4b14ed..4d91676e5dc 100644 --- a/polaris-react/src/components/LegacyCard/tests/LegacyCard.test.tsx +++ b/polaris-react/src/components/LegacyCard/tests/LegacyCard.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Badge} from '../../Badge'; diff --git a/polaris-react/src/components/LegacyStack/LegacyStack.stories.tsx b/polaris-react/src/components/LegacyStack/LegacyStack.stories.tsx index f007841ac34..d903e884bae 100644 --- a/polaris-react/src/components/LegacyStack/LegacyStack.stories.tsx +++ b/polaris-react/src/components/LegacyStack/LegacyStack.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import {Badge, Text, LegacyStack} from '@shopify/polaris'; diff --git a/polaris-react/src/components/LegacyStack/LegacyStack.tsx b/polaris-react/src/components/LegacyStack/LegacyStack.tsx index f5a69208ea9..58f7a386a87 100644 --- a/polaris-react/src/components/LegacyStack/LegacyStack.tsx +++ b/polaris-react/src/components/LegacyStack/LegacyStack.tsx @@ -1,4 +1,4 @@ -import React, {memo, NamedExoticComponent} from 'react'; +import {memo, NamedExoticComponent} from 'react'; import {classNames, variationName} from '../../utilities/css'; import {elementChildren, wrapWithComponent} from '../../utilities/components'; diff --git a/polaris-react/src/components/LegacyStack/components/Item/Item.tsx b/polaris-react/src/components/LegacyStack/components/Item/Item.tsx index 450131f7a5a..4b522d989ef 100644 --- a/polaris-react/src/components/LegacyStack/components/Item/Item.tsx +++ b/polaris-react/src/components/LegacyStack/components/Item/Item.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {classNames} from '../../../../utilities/css'; import styles from '../../LegacyStack.scss'; diff --git a/polaris-react/src/components/LegacyStack/tests/LegacyStack.test.tsx b/polaris-react/src/components/LegacyStack/tests/LegacyStack.test.tsx index 9551352e7f0..fcf3f18433b 100644 --- a/polaris-react/src/components/LegacyStack/tests/LegacyStack.test.tsx +++ b/polaris-react/src/components/LegacyStack/tests/LegacyStack.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {LegacyStack} from '../LegacyStack'; diff --git a/polaris-react/src/components/Link/Link.stories.tsx b/polaris-react/src/components/Link/Link.stories.tsx index a35fb7ad4d8..5f3cdb08a44 100644 --- a/polaris-react/src/components/Link/Link.stories.tsx +++ b/polaris-react/src/components/Link/Link.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import {Banner, Link} from '@shopify/polaris'; diff --git a/polaris-react/src/components/Link/Link.tsx b/polaris-react/src/components/Link/Link.tsx index f1eb3a6b74a..f573d626051 100644 --- a/polaris-react/src/components/Link/Link.tsx +++ b/polaris-react/src/components/Link/Link.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {BannerContext} from '../../utilities/banner-context'; import {classNames} from '../../utilities/css'; import {UnstyledLink} from '../UnstyledLink'; diff --git a/polaris-react/src/components/Link/tests/Link.test.tsx b/polaris-react/src/components/Link/tests/Link.test.tsx index 41392e52106..adc74291914 100644 --- a/polaris-react/src/components/Link/tests/Link.test.tsx +++ b/polaris-react/src/components/Link/tests/Link.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Banner} from '../../Banner'; diff --git a/polaris-react/src/components/List/List.stories.tsx b/polaris-react/src/components/List/List.stories.tsx index 0d1b2e2a0cf..c945b16d417 100644 --- a/polaris-react/src/components/List/List.stories.tsx +++ b/polaris-react/src/components/List/List.stories.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type {ComponentMeta} from '@storybook/react'; import {List} from '@shopify/polaris'; diff --git a/polaris-react/src/components/List/List.tsx b/polaris-react/src/components/List/List.tsx index 19afc52c5f0..f2cf1c96379 100644 --- a/polaris-react/src/components/List/List.tsx +++ b/polaris-react/src/components/List/List.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {classNames, variationName} from '../../utilities/css'; import {Item} from './components'; diff --git a/polaris-react/src/components/List/components/Item/Item.tsx b/polaris-react/src/components/List/components/Item/Item.tsx index d2ebfdb9353..58f6e1317b9 100644 --- a/polaris-react/src/components/List/components/Item/Item.tsx +++ b/polaris-react/src/components/List/components/Item/Item.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import styles from '../../List.scss'; export interface ItemProps { diff --git a/polaris-react/src/components/List/components/Item/tests/Item.test.tsx b/polaris-react/src/components/List/components/Item/tests/Item.test.tsx index a0f611eab95..5e39bdbc8b7 100644 --- a/polaris-react/src/components/List/components/Item/tests/Item.test.tsx +++ b/polaris-react/src/components/List/components/Item/tests/Item.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Item} from '../Item'; diff --git a/polaris-react/src/components/List/tests/List.test.tsx b/polaris-react/src/components/List/tests/List.test.tsx index 9bff04fee95..863c1457f9a 100644 --- a/polaris-react/src/components/List/tests/List.test.tsx +++ b/polaris-react/src/components/List/tests/List.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {List} from '../List'; diff --git a/polaris-react/src/components/Listbox/Listbox.stories.tsx b/polaris-react/src/components/Listbox/Listbox.stories.tsx index 8718bcaca90..ebc3394ff75 100644 --- a/polaris-react/src/components/Listbox/Listbox.stories.tsx +++ b/polaris-react/src/components/Listbox/Listbox.stories.tsx @@ -1,4 +1,4 @@ -import React, {useState} from 'react'; +import { useState } from 'react'; import type {ComponentMeta} from '@storybook/react'; import { LegacyCard, diff --git a/polaris-react/src/components/Listbox/Listbox.tsx b/polaris-react/src/components/Listbox/Listbox.tsx index 805ccc16ac7..c3a689ac010 100644 --- a/polaris-react/src/components/Listbox/Listbox.tsx +++ b/polaris-react/src/components/Listbox/Listbox.tsx @@ -1,16 +1,16 @@ -import React, { +import { useState, useRef, useEffect, useCallback, ReactNode, useMemo, + useId, Children, } from 'react'; import {debounce} from '../../utilities/debounce'; import {useToggle} from '../../utilities/use-toggle'; -import {useUniqueId} from '../../utilities/unique-id'; import {useComboboxListbox} from '../../utilities/combobox'; import { ListboxContext, @@ -88,7 +88,7 @@ export function Listbox({ setFalse: disableKeyboardEvents, } = useToggle(Boolean(enableKeyboardControl)); - const uniqueId = useUniqueId('Listbox'); + const uniqueId = useId(); const listId = customListId || uniqueId; const scrollableRef = useRef(null); diff --git a/polaris-react/src/components/Listbox/components/Action/Action.tsx b/polaris-react/src/components/Listbox/components/Action/Action.tsx index ffaf5496dd4..5db65b63397 100644 --- a/polaris-react/src/components/Listbox/components/Action/Action.tsx +++ b/polaris-react/src/components/Listbox/components/Action/Action.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import {Icon} from '../../../Icon'; import type {IconProps} from '../../../Icon'; import {Option, OptionProps} from '../Option'; diff --git a/polaris-react/src/components/Listbox/components/Action/tests/Action.test.tsx b/polaris-react/src/components/Listbox/components/Action/tests/Action.test.tsx index a0370452a2e..7c20b36171e 100644 --- a/polaris-react/src/components/Listbox/components/Action/tests/Action.test.tsx +++ b/polaris-react/src/components/Listbox/components/Action/tests/Action.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {CirclePlusMinor, AddMajor} from '@shopify/polaris-icons'; import {mountWithListboxProvider} from 'tests/utilities/listbox'; diff --git a/polaris-react/src/components/Listbox/components/Header/Header.tsx b/polaris-react/src/components/Listbox/components/Header/Header.tsx index 4ff346844b3..0afcb1a0e8d 100644 --- a/polaris-react/src/components/Listbox/components/Header/Header.tsx +++ b/polaris-react/src/components/Listbox/components/Header/Header.tsx @@ -1,4 +1,4 @@ -import React, {ReactNode} from 'react'; +import { ReactNode } from 'react'; import {useSection} from '../Section'; import {Box} from '../../../Box'; diff --git a/polaris-react/src/components/Listbox/components/Header/tests/Header.test.tsx b/polaris-react/src/components/Listbox/components/Header/tests/Header.test.tsx index c236df039a0..64411667bf5 100644 --- a/polaris-react/src/components/Listbox/components/Header/tests/Header.test.tsx +++ b/polaris-react/src/components/Listbox/components/Header/tests/Header.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {Header} from '../Header'; diff --git a/polaris-react/src/components/Listbox/components/Loading/Loading.tsx b/polaris-react/src/components/Listbox/components/Loading/Loading.tsx index ee1f4b50261..e9768314f44 100644 --- a/polaris-react/src/components/Listbox/components/Loading/Loading.tsx +++ b/polaris-react/src/components/Listbox/components/Loading/Loading.tsx @@ -1,4 +1,4 @@ -import React, {memo, useEffect} from 'react'; +import {memo, useEffect} from 'react'; import {Spinner} from '../../../Spinner'; import {useListbox} from '../../../../utilities/listbox'; diff --git a/polaris-react/src/components/Listbox/components/Loading/tests/Loading.test.tsx b/polaris-react/src/components/Listbox/components/Loading/tests/Loading.test.tsx index 1f706d18355..85b5edb2f2b 100644 --- a/polaris-react/src/components/Listbox/components/Loading/tests/Loading.test.tsx +++ b/polaris-react/src/components/Listbox/components/Loading/tests/Loading.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mountWithApp} from 'tests/utilities'; import {ListboxContext} from '../../../../../utilities/listbox'; diff --git a/polaris-react/src/components/Listbox/components/Option/Option.tsx b/polaris-react/src/components/Listbox/components/Option/Option.tsx index f991c2e64b6..93d078ef66b 100644 --- a/polaris-react/src/components/Listbox/components/Option/Option.tsx +++ b/polaris-react/src/components/Listbox/components/Option/Option.tsx @@ -1,7 +1,6 @@ -import React, {useRef, useCallback, memo, useContext} from 'react'; +import {useRef, useCallback, memo, useContext, useId} from 'react'; import {classNames} from '../../../../utilities/css'; -import {useUniqueId} from '../../../../utilities/unique-id'; import {useListbox} from '../../../../utilities/listbox'; import {useSection, listboxWithinSectionDataSelector} from '../Section'; import {TextOption} from '../TextOption'; @@ -40,7 +39,7 @@ export const Option = memo(function Option({ useContext(MappedActionContext); const listItemRef = useRef(null); - const domId = useUniqueId('ListboxOption'); + const domId = useId(); const sectionId = useSection(); const isWithinSection = Boolean(sectionId); diff --git a/polaris-react/src/components/Listbox/components/Option/tests/Option.test.tsx b/polaris-react/src/components/Listbox/components/Option/tests/Option.test.tsx index e5b13c89147..0519523b80e 100644 --- a/polaris-react/src/components/Listbox/components/Option/tests/Option.test.tsx +++ b/polaris-react/src/components/Listbox/components/Option/tests/Option.test.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import {mount} from 'tests/utilities'; import {mountWithListboxProvider} from 'tests/utilities/listbox'; diff --git a/polaris-react/src/components/Listbox/components/Section/Section.tsx b/polaris-react/src/components/Listbox/components/Section/Section.tsx index 2578e2a86a0..9624b160a2c 100644 --- a/polaris-react/src/components/Listbox/components/Section/Section.tsx +++ b/polaris-react/src/components/Listbox/components/Section/Section.tsx @@ -1,7 +1,6 @@ -import React, {ReactNode} from 'react'; +import { ReactNode, useId } from 'react'; import {classNames} from '../../../../utilities/css'; -import {useUniqueId} from '../../../../utilities/unique-id'; import {listboxSectionDataSelector} from './selectors'; import {SectionContext} from './context'; @@ -14,15 +13,15 @@ interface SectionProps { } export function Section({children, divider = true, title}: SectionProps) { - const sectionId = useUniqueId('ListboxSection'); + const id = useId(); return ( - +
  • {title}