feat: update useSnapPoints to improve drawer snapping behavior and add new features
Publish to NPM / Check version changes and publish (push) Successful in 11m14s

This commit is contained in:
2026-08-03 21:11:47 +07:00
parent f444feb7b3
commit 85313c6046
37 changed files with 3216 additions and 461 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@robonen/stdlib",
"version": "0.0.11",
"version": "0.0.12",
"license": "Apache-2.0",
"description": "A collection of tools, utilities, and helpers for TypeScript",
"keywords": [
@@ -21,4 +21,28 @@ describe('createMachine', () => {
it('send returns the (typed) resulting state', () => {
expectTypeOf(machine.send('START')).toEqualTypeOf<'idle' | 'running'>();
});
it('empty terminal nodes do not widen the event union to string', () => {
const terminal = createMachine({
initial: 'idle',
states: {
idle: { on: { START: 'done' } },
done: {},
},
});
expectTypeOf(terminal.send).parameter(0).toEqualTypeOf<'START'>();
});
it('entry/exit-only nodes do not widen the event union either', () => {
const hooked = createMachine({
initial: 'idle',
states: {
idle: { on: { START: 'done' } },
done: { entry: () => {} },
},
});
expectTypeOf(hooked.send).parameter(0).toEqualTypeOf<'START'>();
});
});
@@ -418,6 +418,7 @@ describe('asyncStateMachine', () => {
},
});
// @ts-expect-error -- deliberately undeclared event: runtime must ignore it
const result = await machine.send('STOP');
expect(result).toBe('idle');
@@ -597,6 +598,7 @@ describe('asyncStateMachine', () => {
},
});
// @ts-expect-error -- deliberately undeclared event: can() must report false
expect(await machine.can('STOP')).toBe(false);
});
@@ -57,8 +57,12 @@ export type AsyncStateNodeConfig<Context> = StateNodeConfig<Context, MaybePromis
export type ExtractStates<T> = keyof T & string;
// `on` is matched as REQUIRED here on purpose: an empty terminal node (`{}`)
// satisfies an optional-`on` pattern with no inference candidate, so `infer E`
// would fall back to its constraint and collapse the whole union to `string`,
// silently accepting any event name in `send`/`can`.
export type ExtractEvents<T> = {
[K in keyof T]: T[K] extends { readonly on?: Readonly<Record<infer E extends string, unknown>> }
[K in keyof T]: T[K] extends { readonly on: Readonly<Record<infer E extends string, unknown>> }
? E
: never;
}[keyof T];