Skip to content

Commit

Permalink
chore(shortcut): re-expose public typedef
Browse files Browse the repository at this point in the history
  • Loading branch information
vnphanquang committed Jul 11, 2024
1 parent d3c4b06 commit 2414af5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-countries-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@svelte-put/shortcut': patch
---

re-expose public typedef (following https://github.com/Rich-Harris/dts-buddy/pull/82)
10 changes: 1 addition & 9 deletions packages/shortcut/src/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
// Copyright (c) Quang Phan. All rights reserved. Licensed under the MIT license.

export { shortcut } from './shortcut.js';
export * from './types.public.js';

/**
* Deprecated, use `ShortcutParameter` instead
* @typedef {import('./public').ShortcutParameter} ShortcutParameters
*/

/**
* Deprecated, use `ShortcutEventDetail` instead
* @typedef {import('./public').ShortcutEventDetail} ShortcutEventDetails
*/
9 changes: 5 additions & 4 deletions packages/shortcut/src/shortcut.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ import { on } from 'svelte/events';
* Either way, only use `callback` or `onshortcut` and not both to
* avoid handler duplication.
* @param {HTMLElement} node - HTMLElement to add event listener to
* @param {import('./public').ShortcutParameter} param - svelte action parameters
* @returns {import('./public').ShortcutActionReturn}
* @param {import('./types.public').ShortcutParameter} param - svelte action parameters
* @returns {import('./types.public').ShortcutActionReturn}
*/
export function shortcut(node, param) {
let { enabled = true, trigger, type = 'keydown' } = param;
Expand All @@ -87,7 +87,7 @@ export function shortcut(node, param) {
*/
function handler(event) {
const normalizedTriggers = Array.isArray(trigger) ? trigger : [trigger];
/** @type {Record<import('./public').ShortcutModifier, boolean>} */
/** @type {Record<import('./types.public').ShortcutModifier, boolean>} */
const modifiedMap = {
alt: event.altKey,
ctrl: event.ctrlKey,
Expand All @@ -114,7 +114,7 @@ export function shortcut(node, param) {
}
if (event.key === key) {
if (preventDefault) event.preventDefault();
/** @type {import('./public').ShortcutEventDetail} */
/** @type {import('./types.public').ShortcutEventDetail} */
const detail = {
node,
trigger: mergedTrigger,
Expand Down Expand Up @@ -152,3 +152,4 @@ export function shortcut(node, param) {
},
};
}

File renamed without changes.
3 changes: 3 additions & 0 deletions packages/shortcut/src/types.public.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/** to provide typing only, see types.public.d.ts */
export {};

0 comments on commit 2414af5

Please sign in to comment.