From 9f982d2f83e81608575cc459c35bc2af796d4b7a Mon Sep 17 00:00:00 2001 From: BoussonKarel Date: Thu, 5 Oct 2023 15:30:02 +0200 Subject: [PATCH] add typescript declarations (for Glint) --- ember-click-outside/package.json | 15 +++++++++++++-- .../types/modifiers/on-click-outside.d.ts | 17 +++++++++++++++++ .../types/template-registry.d.ts | 5 +++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 ember-click-outside/types/modifiers/on-click-outside.d.ts create mode 100644 ember-click-outside/types/template-registry.d.ts diff --git a/ember-click-outside/package.json b/ember-click-outside/package.json index 82124db..ad1a8de 100644 --- a/ember-click-outside/package.json +++ b/ember-click-outside/package.json @@ -10,7 +10,8 @@ "author": "Gabor Babicz ", "files": [ "addon-main.js", - "dist" + "dist", + "types" ], "scripts": { "build": "rollup --config", @@ -63,7 +64,17 @@ }, "exports": { ".": "./dist/index.js", - "./*": "./dist/*.js", + "./*": { + "types": "./types/*.d.ts", + "default": "./dist/*.js" + }, "./addon-main.js": "./addon-main.js" + }, + "typesVersions": { + "*": { + "*": [ + "types/*" + ] + } } } diff --git a/ember-click-outside/types/modifiers/on-click-outside.d.ts b/ember-click-outside/types/modifiers/on-click-outside.d.ts new file mode 100644 index 0000000..6a14150 --- /dev/null +++ b/ember-click-outside/types/modifiers/on-click-outside.d.ts @@ -0,0 +1,17 @@ +import type Modifier from 'ember-modifier'; + +export interface ClickOutsideSignature { + Element?: HTMLElement; + Args: { + Positional: [action: (event: Event) => unknown]; + Named: + | never + | { + capture?: boolean; + eventType?: keyof DocumentEventMap; + exceptSelector?: string; + }; + }; +} + +export default class ClickOutsideModifier extends Modifier {} diff --git a/ember-click-outside/types/template-registry.d.ts b/ember-click-outside/types/template-registry.d.ts new file mode 100644 index 0000000..329f95b --- /dev/null +++ b/ember-click-outside/types/template-registry.d.ts @@ -0,0 +1,5 @@ +import OnClickOutside from './modifiers/on-click-outside'; + +export default class EmberClickOutsideRegistry { + 'on-click-outside': typeof OnClickOutside; +}