From 8d11f241e569152a2566053a4eb5efdb68eeb8b4 Mon Sep 17 00:00:00 2001 From: Jan Potoms <2109932+Janpot@users.noreply.github.com> Date: Thu, 27 Feb 2025 09:27:25 +0100 Subject: [PATCH 1/4] [code-infra] Fix build:types not copying on some setups (#1482) --- scripts/buildTypes.mts | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/scripts/buildTypes.mts b/scripts/buildTypes.mts index f6decac6f6..4c430d3c65 100644 --- a/scripts/buildTypes.mts +++ b/scripts/buildTypes.mts @@ -1,5 +1,5 @@ /* eslint-disable no-console */ -import { cp, readFile } from 'node:fs/promises'; +import { cp, stat, readFile } from 'node:fs/promises'; import path from 'node:path'; import { $ } from 'execa'; import { parse } from 'jsonc-parser'; @@ -26,12 +26,11 @@ async function run(options: RunOptions) { compilerOptions: { outDir }, } = tsConfig; - const promises: Promise[] = []; - for (const destination of options.copy) { - copyDeclarations(outDir, destination); - } + const promises: Promise[] = options.copy.map((destination) => + copyDeclarations(outDir, destination), + ); - await Promise.allSettled(promises); + await Promise.all(promises); } function emitDeclarations(tsconfig: string) { @@ -50,9 +49,19 @@ async function copyDeclarations(sourceDirectory: string, destinationDirectory: s console.log(`Copying declarations from ${fullSourceDirectory} to ${fullDestinationDirectory}`); - return cp(fullSourceDirectory, fullDestinationDirectory, { + await cp(fullSourceDirectory, fullDestinationDirectory, { recursive: true, - filter: (src) => !src.includes('.') || src.endsWith('.d.ts'), // include directories and .d.ts files + filter: async (src) => { + if (src.startsWith('.')) { + // ignore dotfiles + return false; + } + const stats = await stat(src); + if (stats.isDirectory()) { + return true; + } + return src.endsWith('.d.ts'); + }, }); } From b0defb4dfe4cf9f82b815ed3a71587b48027bd74 Mon Sep 17 00:00:00 2001 From: Albert Yu Date: Thu, 27 Feb 2025 20:46:37 +0800 Subject: [PATCH 2/4] [Slider] Warn when `min` is not less than `max` (#1475) --- packages/react/src/slider/root/useSliderRoot.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/react/src/slider/root/useSliderRoot.ts b/packages/react/src/slider/root/useSliderRoot.ts index 45f2db85d2..e5065f4f25 100644 --- a/packages/react/src/slider/root/useSliderRoot.ts +++ b/packages/react/src/slider/root/useSliderRoot.ts @@ -10,6 +10,7 @@ import { useControlled } from '../../utils/useControlled'; import { useEnhancedEffect } from '../../utils/useEnhancedEffect'; import { useForkRef } from '../../utils/useForkRef'; import { valueToPercent } from '../../utils/valueToPercent'; +import { warn } from '../../utils/warn'; import type { CompositeMetadata } from '../../composite/list/CompositeList'; import { useDirection } from '../../direction-provider/DirectionContext'; import { useField } from '../../field/useField'; @@ -216,7 +217,7 @@ export function useSliderRoot(parameters: useSliderRoot.Parameters): useSliderRo thumbIndex: number, event: Event, ) => { - if (areValuesEqual(newValue, valueUnwrapped)) { + if (Number.isNaN(newValue) || areValuesEqual(newValue, valueUnwrapped)) { return; } @@ -375,9 +376,13 @@ export function useSliderRoot(parameters: useSliderRoot.Parameters): useSliderRo return; } + if (min >= max) { + warn('Slider `max` must be greater than `min`'); + } + if (typeof valueUnwrapped === 'number') { const newPercentageValue = valueToPercent(valueUnwrapped, min, max); - if (newPercentageValue !== percentageValues[0]) { + if (newPercentageValue !== percentageValues[0] && !Number.isNaN(newPercentageValue)) { setPercentageValues([newPercentageValue]); } } else if (Array.isArray(valueUnwrapped)) { From 39f2743c216db3348a3f4086d81a3694efa01c9b Mon Sep 17 00:00:00 2001 From: atomiks Date: Fri, 28 Feb 2025 15:35:03 +1100 Subject: [PATCH 3/4] [test] Fix PreviewCard test flake (#1487) --- .../app/(public)/(content)/react/handbook/animation/page.mdx | 2 +- packages/react/src/alert-dialog/root/AlertDialogRoot.test.tsx | 2 +- packages/react/src/dialog/root/DialogRoot.test.tsx | 2 +- packages/react/src/menu/root/MenuRoot.test.tsx | 2 +- packages/react/src/popover/root/PopoverRoot.test.tsx | 2 +- packages/react/src/preview-card/root/PreviewCardRoot.test.tsx | 2 +- packages/react/src/select/root/SelectRoot.test.tsx | 2 +- packages/react/src/tooltip/root/TooltipRoot.test.tsx | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/src/app/(public)/(content)/react/handbook/animation/page.mdx b/docs/src/app/(public)/(content)/react/handbook/animation/page.mdx index 393967a16b..a655a451af 100644 --- a/docs/src/app/(public)/(content)/react/handbook/animation/page.mdx +++ b/docs/src/app/(public)/(content)/react/handbook/animation/page.mdx @@ -183,7 +183,7 @@ function App() { exit={{ scale: 0 }} onAnimationComplete={() => { if (!open) { - action.current.unmount(); + actionsRef.current.unmount(); } }} /> diff --git a/packages/react/src/alert-dialog/root/AlertDialogRoot.test.tsx b/packages/react/src/alert-dialog/root/AlertDialogRoot.test.tsx index 0b572d37a6..82173a0df9 100644 --- a/packages/react/src/alert-dialog/root/AlertDialogRoot.test.tsx +++ b/packages/react/src/alert-dialog/root/AlertDialogRoot.test.tsx @@ -130,7 +130,7 @@ describe('', () => { }); }); - describe('prop: action', () => { + describe('prop: actionsRef', () => { it('unmounts the alert dialog when the `unmount` method is called', async () => { const actionsRef = { current: { diff --git a/packages/react/src/dialog/root/DialogRoot.test.tsx b/packages/react/src/dialog/root/DialogRoot.test.tsx index 1f8ace8a7d..8224d8972f 100644 --- a/packages/react/src/dialog/root/DialogRoot.test.tsx +++ b/packages/react/src/dialog/root/DialogRoot.test.tsx @@ -597,7 +597,7 @@ describe('', () => { }); }); - describe('prop: action', () => { + describe('prop: actionsRef', () => { it('unmounts the dialog when the `unmount` method is called', async () => { const actionsRef = { current: { diff --git a/packages/react/src/menu/root/MenuRoot.test.tsx b/packages/react/src/menu/root/MenuRoot.test.tsx index 27714c7c5a..3319dfc063 100644 --- a/packages/react/src/menu/root/MenuRoot.test.tsx +++ b/packages/react/src/menu/root/MenuRoot.test.tsx @@ -799,7 +799,7 @@ describe('', () => { }); }); - describe('prop: action', () => { + describe('prop: actionsRef', () => { it('unmounts the menu when the `unmount` method is called', async () => { const actionsRef = { current: { diff --git a/packages/react/src/popover/root/PopoverRoot.test.tsx b/packages/react/src/popover/root/PopoverRoot.test.tsx index 7b7d8cbae1..e4c7cce5cc 100644 --- a/packages/react/src/popover/root/PopoverRoot.test.tsx +++ b/packages/react/src/popover/root/PopoverRoot.test.tsx @@ -408,7 +408,7 @@ describe('', () => { }); }); - describe('prop: action', () => { + describe('prop: actionsRef', () => { it('unmounts the popover when the `unmount` method is called', async () => { const actionsRef = { current: { diff --git a/packages/react/src/preview-card/root/PreviewCardRoot.test.tsx b/packages/react/src/preview-card/root/PreviewCardRoot.test.tsx index cebc5b025c..71f0828e17 100644 --- a/packages/react/src/preview-card/root/PreviewCardRoot.test.tsx +++ b/packages/react/src/preview-card/root/PreviewCardRoot.test.tsx @@ -385,7 +385,7 @@ describe('', () => { }); }); - describe('prop: action', () => { + describe.skipIf(isJSDOM)('prop: actionsRef', () => { it('unmounts the preview card when the `unmount` method is called', async () => { const actionsRef = { current: { diff --git a/packages/react/src/select/root/SelectRoot.test.tsx b/packages/react/src/select/root/SelectRoot.test.tsx index 6c73a361e2..ae84e79b98 100644 --- a/packages/react/src/select/root/SelectRoot.test.tsx +++ b/packages/react/src/select/root/SelectRoot.test.tsx @@ -322,7 +322,7 @@ describe('', () => { }); }); - describe('prop: action', () => { + describe('prop: actionsRef', () => { it('unmounts the select when the `unmount` method is called', async () => { const actionsRef = { current: { diff --git a/packages/react/src/tooltip/root/TooltipRoot.test.tsx b/packages/react/src/tooltip/root/TooltipRoot.test.tsx index 81add72f66..16d1f4d58e 100644 --- a/packages/react/src/tooltip/root/TooltipRoot.test.tsx +++ b/packages/react/src/tooltip/root/TooltipRoot.test.tsx @@ -381,7 +381,7 @@ describe('', () => { }); }); - describe('prop: action', () => { + describe('prop: actionsRef', () => { it('unmounts the tooltip when the `unmount` method is called', async () => { const actionsRef = { current: { From e05da2328a636a034382f287577ad1e13edb33a0 Mon Sep 17 00:00:00 2001 From: atomiks Date: Fri, 28 Feb 2025 16:11:25 +1100 Subject: [PATCH 4/4] [test] Fix wrong env skip (#1490) --- packages/react/src/preview-card/root/PreviewCardRoot.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react/src/preview-card/root/PreviewCardRoot.test.tsx b/packages/react/src/preview-card/root/PreviewCardRoot.test.tsx index 71f0828e17..8449ec4fa8 100644 --- a/packages/react/src/preview-card/root/PreviewCardRoot.test.tsx +++ b/packages/react/src/preview-card/root/PreviewCardRoot.test.tsx @@ -385,7 +385,7 @@ describe('', () => { }); }); - describe.skipIf(isJSDOM)('prop: actionsRef', () => { + describe.skipIf(!isJSDOM)('prop: actionsRef', () => { it('unmounts the preview card when the `unmount` method is called', async () => { const actionsRef = { current: {