Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions documentation/guides/migrating-from-v10-to-v11.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ Polaris v11.0.0 ([full release notes](https://github.com/Shopify/polaris/release

NodeJS version 14 is no longer supported. NodeJS 18 is recommended and 16 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
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
"@types/jest": "^27.5.1",
"@types/node": "^18.11.18",
"babel-loader": "^9.1.2",
"downlevel-dts": "^0.6.0",
"eslint": "^8.3.0",
"execa": "^5.0.0",
"jest": "^27.5.1",
Expand All @@ -85,7 +84,7 @@
"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": [
Expand Down
3 changes: 0 additions & 3 deletions polaris-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
"@oclif/core": "^1.13.10",
"@shopify/polaris-migrator": "^0.11.3"
},
"devDependencies": {
"typescript": "^4.7.4"
},
"engine-strict": true,
"engines": {
"node": "^16.13.0 || >=18.12.0"
Expand Down
12 changes: 2 additions & 10 deletions polaris-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,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",
Expand Down
4 changes: 1 addition & 3 deletions polaris-react/scripts/build-validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,12 +539,8 @@ function firstOption(
options?: OptionDescriptor[],
sections?: OptionListProps['sections'],
): string {
const firstOptionsValue =
options == null || options === [] ? '' : options[0].value;
const firstSectionOptionsValue =
sections == null || sections === [] || sections[0].options === []
? ''
: sections[0].options[0].value;
const firstOptionsValue = options?.[0]?.value ?? '';
const firstSectionOptionsValue = sections?.[0]?.options?.[0]?.value ?? '';
return firstOptionsValue || firstSectionOptionsValue;
}

Expand Down
29 changes: 13 additions & 16 deletions polaris-react/src/components/ResourceList/ResourceList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, {
ReactElement,
useCallback,
useEffect,
useReducer,
Expand Down Expand Up @@ -41,7 +40,11 @@ import styles from './ResourceList.scss';
const SMALL_SPINNER_HEIGHT = 28;
const LARGE_SPINNER_HEIGHT = 45;

function getAllItemsOnPage<TItemType>(
interface ResourceListItemData {
[data: string]: any;
}

function getAllItemsOnPage<TItemType extends ResourceListItemData>(
items: TItemType[],
idForItem: (item: TItemType, index: number) => string,
) {
Expand All @@ -57,16 +60,16 @@ const isBreakpointsXS = () => {
parseFloat(toPx(tokens.breakpoints['breakpoints-sm']) ?? '');
};

function defaultIdForItem<TItemType extends {id?: any}>(
function defaultIdForItem<TItemType extends ResourceListItemData>(
item: TItemType,
index: number,
) {
return Object.prototype.hasOwnProperty.call(item, 'id')
? item.id
: index.toString();
): string {
return 'id' in item ? item.id : index.toString();
}

export interface ResourceListProps<TItemType = any> {
export interface ResourceListProps<
TItemType extends ResourceListItemData = ResourceListItemData,
> {
/** Item data; each item is passed to renderItem */
items: TItemType[];
filterControl?: React.ReactNode;
Expand Down Expand Up @@ -119,13 +122,7 @@ export interface ResourceListProps<TItemType = any> {
resolveItemId?(item: TItemType): string;
}

type ResourceListType = (<TItemType>(
value: ResourceListProps<TItemType>,
) => ReactElement) & {
Item: typeof ResourceItem;
};

export const ResourceList: ResourceListType = function ResourceList<TItemType>({
export function ResourceList<TItemType extends ResourceListItemData>({
items,
filterControl,
emptyState,
Expand Down Expand Up @@ -767,6 +764,6 @@ export const ResourceList: ResourceListType = function ResourceList<TItemType>({
<div ref={bulkActionsIntersectionRef} />
</ResourceListContext.Provider>
);
};
}

ResourceList.Item = ResourceItem;
2 changes: 1 addition & 1 deletion polaris-react/src/utilities/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function merge<TSource1, TSource2, TSource3, TSource4, TSource5>(
let final = {};

for (const obj of objs) {
final = mergeRecursively(final, obj);
final = mergeRecursively(final, obj as any);
}

return final;
Expand Down
2 changes: 1 addition & 1 deletion polaris-react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"composite": true,
"emitDeclarationOnly": true,
"importsNotUsedAsValues": "error",
"outDir": "build/ts/latest",
"outDir": "build/ts",
"rootDir": "./",
"strictFunctionTypes": false,
"paths": {
Expand Down
4 changes: 4 additions & 0 deletions polaris.shopify.com/content/design/typography.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ Small heading styles, `headingXs` - `headingMd`, and body styles will remain the

![An image showing how heading styles change based on breakpoint](/images/foundations/design/typography/type-responsive-styles@2x.png)

### Uppercase styles

The design language no longer supports uppercase typography. We recommend using the [Text component](/components/text) to apply visual hierarchy. Work with your team to determine a type style that works best for your use case.

---

## Font stack
Expand Down
2 changes: 1 addition & 1 deletion polaris.shopify.com/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@
"rehype-raw": "^6.1.1",
"sass": "^1.49.9",
"style-loader": "^3.3.1",
"typescript": "^4.7.4"
"typescript": "^4.9.3"
}
}
28 changes: 5 additions & 23 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9286,14 +9286,6 @@ dotenv@^8.0.0, dotenv@^8.1.0:
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.6.0.tgz#061af664d19f7f4d8fc6e4ff9b584ce237adcb8b"
integrity sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==

downlevel-dts@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/downlevel-dts/-/downlevel-dts-0.6.0.tgz#1e52db9fa3ad9e3919a36545412f0b41a44289d1"
integrity sha512-Jy3ZZcXWPzTn5jJRW5WpdEtIq8+UowWWi5TEBgHHvzw320kouV//2KgVhfcuOpP93KS3UAokTxnZKU4L75kRSQ==
dependencies:
shelljs "^0.8.3"
typescript "^4.1.0-dev.20200804"

duplexer2@~0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1"
Expand Down Expand Up @@ -19915,7 +19907,7 @@ shell-quote@^1.6.1:
resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.3.tgz#aa40edac170445b9a431e17bb62c0b881b9c4123"
integrity sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==

shelljs@^0.8.3, shelljs@^0.8.5:
shelljs@^0.8.5:
version "0.8.5"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.5.tgz#de055408d8361bed66c669d2f000538ced8ee20c"
integrity sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==
Expand Down Expand Up @@ -21687,20 +21679,10 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typescript@^4.1.0-dev.20200804, typescript@^4.6.3:
version "4.6.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.3.tgz#eefeafa6afdd31d725584c67a0eaba80f6fc6c6c"
integrity sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==

typescript@^4.3.2:
version "4.8.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6"
integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==

typescript@^4.7.4:
version "4.7.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==
typescript@^4.3.2, typescript@^4.9.3:
version "4.9.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.3.tgz#3aea307c1746b8c384435d8ac36b8a2e580d85db"
integrity sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==

typical@^4.0.0:
version "4.0.0"
Expand Down