Skip to content

Commit

Permalink
Export types
Browse files Browse the repository at this point in the history
  • Loading branch information
DaviDevMod committed Apr 29, 2023
1 parent ea2282e commit 0d90cba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-singers-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@davidevmod/focus-trap': patch
---

Export types
14 changes: 10 additions & 4 deletions packages/focus-trap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ import { throwInEnv } from './exceptions.js';
import { Roots, TrapConfig } from './state.js';
import { build, resume, demolish, pause } from './trap-actions.js';

export const focusTrap = (arg: Roots | TrapConfig | 'RESUME' | 'DEMOLISH' | 'PAUSE') => {
type LiteralTrapAction = 'RESUME' | 'DEMOLISH' | 'PAUSE';

type TrapAction = Roots | TrapConfig | LiteralTrapAction;

export const focusTrap = (arg: TrapAction) => {
const result =
typeof arg === 'string'
? arg === 'RESUME'
? resume()
: arg === 'DEMOLISH'
? arg === 'DEMOLISH'
? demolish()
: arg === 'RESUME'
? resume()
: pause()
: build(Array.isArray(arg) ? { roots: arg } : arg);

if (result.isErr) throwInEnv(result.error);
};

export type { Roots, TrapConfig, LiteralTrapAction, TrapAction };

2 comments on commit 0d90cba

@vercel
Copy link

@vercel vercel bot commented on 0d90cba Apr 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

focus-trap-demo-q37s – ./apps/demo

focus-trap-demo-q37s-davidevmod.vercel.app
focus-trap-demo-q37s-git-main-davidevmod.vercel.app
focus-trap-demo-q37s.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 0d90cba Apr 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

focus-trap-demo – ./apps/demo

focus-trap-demo.vercel.app
focus-trap-demo-git-main-davidevmod.vercel.app
focus-trap-demo-davidevmod.vercel.app

Please sign in to comment.