-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
109 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
import { core_config } from '../config'; | ||
import { defineConfig } from 'tsup'; | ||
|
||
export default core_config({ modularAsIndex: false }); | ||
export default defineConfig([ | ||
{ | ||
entry: { | ||
index: `./src/core.ts`, | ||
plugins: `./src/plugins.ts`, | ||
}, | ||
format: 'esm', | ||
dts: { resolve: true }, | ||
clean: true, | ||
treeshake: 'smallest', | ||
}, | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,13 @@ | ||
import { | ||
draggable as core_draggable, | ||
Plugin, | ||
type DragEventData, | ||
} from '@neodrag/core'; | ||
|
||
//!THIS IS HACK, WE WANNA IMPORT THE TYPE WHEN THE ISSUE IS FIXED LATER | ||
/** | ||
* Actions can return an object containing the two properties defined in this interface. Both are optional. | ||
* - update: An action can have a parameter. This method will be called whenever that parameter changes, | ||
* immediately after Svelte has applied updates to the markup. `ActionReturn` and `ActionReturn<undefined>` both | ||
* mean that the action accepts no parameters. | ||
* - destroy: Method that is called after the element is unmounted | ||
* | ||
* Additionally, you can specify which additional attributes and events the action enables on the applied element. | ||
* This applies to TypeScript typings only and has no effect at runtime. | ||
* | ||
* Example usage: | ||
* ```ts | ||
* interface Attributes { | ||
* newprop?: string; | ||
* 'on:event': (e: CustomEvent<boolean>) => void; | ||
* } | ||
* | ||
* export function myAction(node: HTMLElement, parameter: Parameter): ActionReturn<Parameter, Attributes> { | ||
* // ... | ||
* return { | ||
* update: (updatedParameter) => {...}, | ||
* destroy: () => {...} | ||
* }; | ||
* } | ||
* ``` | ||
* | ||
* Docs: https://svelte.dev/docs/svelte-action | ||
*/ | ||
export interface ActionReturn< | ||
Parameter = undefined, | ||
Attributes extends Record<string, any> = Record<never, any>, | ||
> { | ||
update?: (parameter: Parameter) => void; | ||
destroy?: () => void; | ||
/** | ||
* ### DO NOT USE THIS | ||
* This exists solely for type-checking and has no effect at runtime. | ||
* Set this through the `Attributes` generic instead. | ||
*/ | ||
$$_attributes?: Attributes; | ||
} | ||
|
||
/** | ||
* Actions are functions that are called when an element is created. | ||
* You can use this interface to type such actions. | ||
* The following example defines an action that only works on `<div>` elements | ||
* and optionally accepts a parameter which it has a default value for: | ||
* ```ts | ||
* export const myAction: Action<HTMLDivElement, { someProperty: boolean } | undefined> = (node, param = { someProperty: true }) => { | ||
* // ... | ||
* } | ||
* ``` | ||
* `Action<HTMLDivElement>` and `Action<HTMLDivElement, undefined>` both signal that the action accepts no parameters. | ||
* | ||
* You can return an object with methods `update` and `destroy` from the function and type which additional attributes and events it has. | ||
* See interface `ActionReturn` for more details. | ||
* | ||
* Docs: https://svelte.dev/docs/svelte-action | ||
*/ | ||
export interface Action< | ||
Element = HTMLElement, | ||
Parameter = undefined, | ||
Attributes extends Record<string, any> = Record<never, any>, | ||
> { | ||
<Node extends Element>( | ||
...args: undefined extends Parameter | ||
? [node: Node, parameter?: Parameter] | ||
: [node: Node, parameter: Parameter] | ||
): void | ActionReturn<Parameter, Attributes>; | ||
} | ||
|
||
export const draggable = core_draggable as Action< | ||
HTMLElement, | ||
Plugin[] | undefined, | ||
{ | ||
onneodrag_start: (e: CustomEvent<DragEventData>) => void; | ||
onneodrag: (e: CustomEvent<DragEventData>) => void; | ||
onneodrag_end: (e: CustomEvent<DragEventData>) => void; | ||
} | ||
>; | ||
|
||
export * from '@neodrag/core'; | ||
import { createDraggable, DEFAULT_delegate, DEFAULT_onError, DEFAULT_plugins } from '@neodrag/core'; | ||
import type { Plugin } from '@neodrag/core/plugins'; | ||
import type { Action } from 'svelte/action'; | ||
|
||
const { draggable: core, instances } = createDraggable({ | ||
delegate: DEFAULT_delegate, | ||
plugins: DEFAULT_plugins, | ||
onError: DEFAULT_onError, | ||
}); | ||
|
||
export const draggable = core as Action<HTMLElement | SVGElement, Plugin[] | undefined>; | ||
export { instances }; | ||
export * from '@neodrag/core/plugins'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
import { core_config } from '../config'; | ||
import { defineConfig } from 'tsup'; | ||
|
||
export default core_config({}); | ||
export default defineConfig([ | ||
{ | ||
entry: [`./src/index.ts`], | ||
format: 'esm', | ||
dts: { resolve: true }, | ||
external: ['svelte/action', '@neodrag/core'], | ||
clean: true, | ||
treeshake: 'smallest', | ||
}, | ||
]); |
Oops, something went wrong.