diff --git a/packages/utilities/env/package.json b/packages/utilities/env/package.json new file mode 100644 index 0000000000..b30d41f40c --- /dev/null +++ b/packages/utilities/env/package.json @@ -0,0 +1,4 @@ +{ + "main": "dist/ui-machines-utils-env.cjs.js", + "module": "dist/ui-machines-utils-env.esm.js" +} diff --git a/packages/utilities/package.json b/packages/utilities/package.json index b4a4071d59..e8d50bb342 100644 --- a/packages/utilities/package.json +++ b/packages/utilities/package.json @@ -26,6 +26,7 @@ "index.ts", "array.ts", "assertion.ts", + "env.ts", "dom-collection.ts", "dom-event.ts", "dom-helper.ts", @@ -41,6 +42,7 @@ "array", "assertion", "dom-collection", + "env", "dom-event", "dom-helper", "function", diff --git a/packages/utilities/src/dom-event.ts b/packages/utilities/src/dom-event.ts index fd1dddff89..50c3769b12 100644 --- a/packages/utilities/src/dom-event.ts +++ b/packages/utilities/src/dom-event.ts @@ -5,7 +5,7 @@ import { supportsMouseEvents, supportsPointerEvents, supportsTouchEvents, -} from "./environment" +} from "./env" import { cast, runIfFn } from "./function" import { AnyPointerEvent, Point, PointType } from "./point" diff --git a/packages/utilities/src/environment.ts b/packages/utilities/src/env.ts similarity index 100% rename from packages/utilities/src/environment.ts rename to packages/utilities/src/env.ts diff --git a/packages/utilities/src/function.ts b/packages/utilities/src/function.ts index 087f582ed6..f868361241 100644 --- a/packages/utilities/src/function.ts +++ b/packages/utilities/src/function.ts @@ -1,5 +1,5 @@ import { isFunction } from "./assertion" -import { __DEV__ } from "./environment" +import { __DEV__ } from "./env" // schedule task to next tick using double `requestAnimationFrame` export function nextTick(fn: VoidFunction) { diff --git a/packages/utilities/src/index.ts b/packages/utilities/src/index.ts index 2b0120f0f1..33d544dfea 100644 --- a/packages/utilities/src/index.ts +++ b/packages/utilities/src/index.ts @@ -3,9 +3,11 @@ export * from "./assertion" export * from "./dom-collection" export * from "./dom-event" export * from "./dom-helper" -export * from "./environment" +export * from "./env" +export * from "./focus" export * from "./function" export * from "./number" export * from "./point" export * from "./range" export * from "./rect" +export * from "./types" diff --git a/packages/utilities/src/types.ts b/packages/utilities/src/types.ts new file mode 100644 index 0000000000..c36738389d --- /dev/null +++ b/packages/utilities/src/types.ts @@ -0,0 +1,31 @@ +export type Dict = Record + +export type Booleanish = boolean | "true" | "false" + +export type AnyFunction = (...args: any) => void + +export type AnyEventHandler = (event: any) => void + +export type MaybeFunction = + | T + | ((...args: Args) => T) + +export type EventKeys = + | "ArrowDown" + | "ArrowUp" + | "ArrowLeft" + | "ArrowRight" + | "Enter" + | "Space" + | "Tab" + | "Backspace" + | "Control" + | "Meta" + | "Home" + | "End" + | "PageDown" + | "PageUp" + | "Delete" + | "Escape" + | " " + | "Shift"