@isoftdata/svelte-context-menu 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/dist/ContextMenu.svelte +4 -1
- package/dist/DropdownItem.svelte +23 -0
- package/dist/DropdownItem.svelte.d.ts +23 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Svelte ContextMenu
|
|
2
2
|
|
|
3
|
+
A Context/Dropdown menu component, filled with [DropdownItem](DropdownItem.md)s
|
|
4
|
+
|
|
3
5
|
## Install
|
|
4
6
|
|
|
5
7
|
```bash
|
|
@@ -45,12 +47,12 @@ The main way you'll interact with this component is through calling the methods
|
|
|
45
47
|
Right Click to Open Menu
|
|
46
48
|
</button>
|
|
47
49
|
<ContextMenu bind:this={cm}>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
<DropdownItem
|
|
51
|
+
icon="mouse"
|
|
52
|
+
on:click={() => alert("Dropdown Item Clicked!")}
|
|
53
|
+
>
|
|
54
|
+
Click Me!
|
|
55
|
+
</DropdownItem>
|
|
54
56
|
<div class="downdown-divider" />
|
|
55
57
|
<h6 class="dropdown-header">Clicked {cmClicks} time(s)</h6>
|
|
56
58
|
</ContextMenu>
|
package/dist/ContextMenu.svelte
CHANGED
|
@@ -53,7 +53,10 @@ function menuKeydownHandler(event) {
|
|
|
53
53
|
}
|
|
54
54
|
</script>
|
|
55
55
|
|
|
56
|
-
<svelte:window
|
|
56
|
+
<svelte:window
|
|
57
|
+
on:click={close}
|
|
58
|
+
on:keydown={event => event.key === "Escape" && close()}
|
|
59
|
+
/>
|
|
57
60
|
|
|
58
61
|
<div
|
|
59
62
|
{id}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script>import Icon from "@isoftdata/svelte-icon";
|
|
2
|
+
export let icon = null;
|
|
3
|
+
function getIconProps(icon2) {
|
|
4
|
+
if (typeof icon2 === "string") {
|
|
5
|
+
return { icon: icon2, ...defaultIconProps };
|
|
6
|
+
} else {
|
|
7
|
+
return { ...icon2, ...defaultIconProps };
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const defaultIconProps = {
|
|
11
|
+
prefix: "fas",
|
|
12
|
+
fixedWidth: true
|
|
13
|
+
};
|
|
14
|
+
$:
|
|
15
|
+
iconProps = getIconProps(icon);
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<button
|
|
19
|
+
class="dropdown-item"
|
|
20
|
+
type="button"
|
|
21
|
+
on:click
|
|
22
|
+
>{#if $$props.icon}<span class="mr-1"><Icon {...iconProps} /> </span>{/if}<slot />
|
|
23
|
+
</button>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ComponentProps } from "svelte";
|
|
3
|
+
import Icon from "@isoftdata/svelte-icon";
|
|
4
|
+
declare const __propDef: {
|
|
5
|
+
props: {
|
|
6
|
+
[x: string]: any;
|
|
7
|
+
icon?: ComponentProps<Icon>["icon"] | ComponentProps<Icon>;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
click: MouseEvent;
|
|
11
|
+
} & {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
};
|
|
14
|
+
slots: {
|
|
15
|
+
default: {};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type DropdownItemProps = typeof __propDef.props;
|
|
19
|
+
export type DropdownItemEvents = typeof __propDef.events;
|
|
20
|
+
export type DropdownItemSlots = typeof __propDef.slots;
|
|
21
|
+
export default class DropdownItem extends SvelteComponent<DropdownItemProps, DropdownItemEvents, DropdownItemSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {default as default} from './ContextMenu.svelte'
|
|
1
|
+
export { default as default } from './ContextMenu.svelte'
|
|
2
|
+
export { default as DropdownItem } from './DropdownItem.svelte'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isoftdata/svelte-context-menu",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite dev",
|
|
6
6
|
"build": "vite build && npm run package",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"type": "module",
|
|
51
51
|
"prettier": "@isoftdata/prettier-config",
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@floating-ui/dom": "^1.5.3"
|
|
53
|
+
"@floating-ui/dom": "^1.5.3",
|
|
54
|
+
"@isoftdata/svelte-icon": "^1.1.0"
|
|
54
55
|
}
|
|
55
56
|
}
|