Skip to content

Commit

Permalink
Merge branch 'master' into feat/toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
mj12albert authored Feb 28, 2025
2 parents 4183289 + e05da23 commit 78928ad
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function App() {
exit={{ scale: 0 }}
onAnimationComplete={() => {
if (!open) {
action.current.unmount();
actionsRef.current.unmount();
}
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('<AlertDialog.Root />', () => {
});
});

describe('prop: action', () => {
describe('prop: actionsRef', () => {
it('unmounts the alert dialog when the `unmount` method is called', async () => {
const actionsRef = {
current: {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/dialog/root/DialogRoot.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ describe('<Dialog.Root />', () => {
});
});

describe('prop: action', () => {
describe('prop: actionsRef', () => {
it('unmounts the dialog when the `unmount` method is called', async () => {
const actionsRef = {
current: {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/menu/root/MenuRoot.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ describe('<Menu.Root />', () => {
});
});

describe('prop: action', () => {
describe('prop: actionsRef', () => {
it('unmounts the menu when the `unmount` method is called', async () => {
const actionsRef = {
current: {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/popover/root/PopoverRoot.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ describe('<Popover.Root />', () => {
});
});

describe('prop: action', () => {
describe('prop: actionsRef', () => {
it('unmounts the popover when the `unmount` method is called', async () => {
const actionsRef = {
current: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ describe('<PreviewCard.Root />', () => {
});
});

describe('prop: action', () => {
describe.skipIf(!isJSDOM)('prop: actionsRef', () => {
it('unmounts the preview card when the `unmount` method is called', async () => {
const actionsRef = {
current: {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/select/root/SelectRoot.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ describe('<Select.Root />', () => {
});
});

describe('prop: action', () => {
describe('prop: actionsRef', () => {
it('unmounts the select when the `unmount` method is called', async () => {
const actionsRef = {
current: {
Expand Down
9 changes: 7 additions & 2 deletions packages/react/src/slider/root/useSliderRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/tooltip/root/TooltipRoot.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ describe('<Tooltip.Root />', () => {
});
});

describe('prop: action', () => {
describe('prop: actionsRef', () => {
it('unmounts the tooltip when the `unmount` method is called', async () => {
const actionsRef = {
current: {
Expand Down
25 changes: 17 additions & 8 deletions scripts/buildTypes.mts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -26,12 +26,11 @@ async function run(options: RunOptions) {
compilerOptions: { outDir },
} = tsConfig;

const promises: Promise<void>[] = [];
for (const destination of options.copy) {
copyDeclarations(outDir, destination);
}
const promises: Promise<void>[] = options.copy.map((destination) =>
copyDeclarations(outDir, destination),
);

await Promise.allSettled(promises);
await Promise.all(promises);
}

function emitDeclarations(tsconfig: string) {
Expand All @@ -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');
},
});
}

Expand Down

0 comments on commit 78928ad

Please sign in to comment.