@isoftdata/svelte-context-menu 2.0.0 → 2.0.2
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 +2 -2
- package/dist/ContextMenu.svelte +10 -10
- package/dist/ContextMenu.svelte.d.ts +2 -2
- package/dist/DropdownCheckboxItem.svelte +5 -5
- package/dist/DropdownCheckboxItem.svelte.d.ts +3 -3
- package/dist/DropdownItem.svelte +5 -5
- package/dist/DropdownItem.svelte.d.ts +4 -4
- package/package.json +62 -59
package/README.md
CHANGED
package/dist/ContextMenu.svelte
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type { Snippet } from
|
|
3
|
-
import { computePosition, flip, type Placement } from
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import { computePosition, flip, type Placement } from '@floating-ui/dom'
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
id?: string
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
//
|
|
18
18
|
id = `dropdown-menu-${uniqueId}`,
|
|
19
19
|
menuItemClickCloses = true,
|
|
20
|
-
placement =
|
|
20
|
+
placement = 'bottom-start',
|
|
21
21
|
children,
|
|
22
22
|
open: openCb,
|
|
23
23
|
close: closeCb,
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
let show = $state(false)
|
|
27
27
|
let positionLeft = $state(0)
|
|
28
28
|
let positionTop = $state(0)
|
|
29
|
-
let strategy = $state(
|
|
29
|
+
let strategy = $state('absolute')
|
|
30
30
|
|
|
31
31
|
let menu: HTMLElement | undefined = $state()
|
|
32
32
|
|
|
33
|
-
export async function open(event: MouseEvent, targetId: string =
|
|
33
|
+
export async function open(event: MouseEvent, targetId: string = '') {
|
|
34
34
|
event.stopPropagation()
|
|
35
35
|
if (menu) {
|
|
36
36
|
show = true
|
|
@@ -71,22 +71,22 @@
|
|
|
71
71
|
event.stopPropagation()
|
|
72
72
|
const target = event.target as HTMLElement
|
|
73
73
|
console.log(event.key, event.currentTarget, event.target)
|
|
74
|
-
if ((event.key ===
|
|
74
|
+
if ((event.key === ' ' || event.key === 'Enter') && target.tagName === 'BUTTON') {
|
|
75
75
|
target.click()
|
|
76
|
-
} else if (target === event.currentTarget && event.key ===
|
|
77
|
-
target.querySelector(
|
|
76
|
+
} else if (target === event.currentTarget && event.key === 'Tab') {
|
|
77
|
+
target.querySelector('button')?.focus()
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
</script>
|
|
81
81
|
|
|
82
82
|
<svelte:window
|
|
83
83
|
onclick={close}
|
|
84
|
-
onkeydown={event => event.key ===
|
|
84
|
+
onkeydown={event => event.key === 'Escape' && close()}
|
|
85
85
|
/>
|
|
86
86
|
|
|
87
87
|
<div
|
|
88
88
|
{id}
|
|
89
|
-
class="dropdown-menu shadow
|
|
89
|
+
class="dropdown-menu shadow rounded"
|
|
90
90
|
class:show
|
|
91
91
|
style="position: {strategy}; left:{positionLeft}px; top:{positionTop}px;"
|
|
92
92
|
role="menu"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type { ComponentProps, Snippet } from
|
|
3
|
-
import DropdownItem from
|
|
4
|
-
interface Props extends Omit<ComponentProps<typeof DropdownItem>,
|
|
2
|
+
import type { ComponentProps, Snippet } from 'svelte'
|
|
3
|
+
import DropdownItem from './DropdownItem.svelte'
|
|
4
|
+
interface Props extends Omit<ComponentProps<typeof DropdownItem>, 'children'> {
|
|
5
5
|
checked?: boolean
|
|
6
6
|
children?: Snippet<[{ checked: boolean }]>
|
|
7
7
|
}
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
<DropdownItem
|
|
18
18
|
icon={{
|
|
19
|
-
icon: checked ?
|
|
20
|
-
prefix:
|
|
19
|
+
icon: checked ? 'check-square' : 'square',
|
|
20
|
+
prefix: 'far',
|
|
21
21
|
}}
|
|
22
22
|
onclick={event => {
|
|
23
23
|
checked = !checked
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ComponentProps, Snippet } from
|
|
2
|
-
import DropdownItem from
|
|
3
|
-
interface Props extends Omit<ComponentProps<typeof DropdownItem>,
|
|
1
|
+
import type { ComponentProps, Snippet } from 'svelte';
|
|
2
|
+
import DropdownItem from './DropdownItem.svelte';
|
|
3
|
+
interface Props extends Omit<ComponentProps<typeof DropdownItem>, 'children'> {
|
|
4
4
|
checked?: boolean;
|
|
5
5
|
children?: Snippet<[{
|
|
6
6
|
checked: boolean;
|
package/dist/DropdownItem.svelte
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type { ComponentProps, Snippet } from
|
|
3
|
-
import type { HTMLButtonAttributes } from
|
|
4
|
-
import Icon, { getIconProps } from
|
|
2
|
+
import type { ComponentProps, Snippet } from 'svelte'
|
|
3
|
+
import type { HTMLButtonAttributes } from 'svelte/elements'
|
|
4
|
+
import Icon, { getIconProps } from '@isoftdata/svelte-icon'
|
|
5
5
|
|
|
6
6
|
interface Props extends Omit<HTMLButtonAttributes, `on:${string}` | `bind:${string}` | `aria-${string}`> {
|
|
7
|
-
icon?: ComponentProps<Icon>[
|
|
7
|
+
icon?: ComponentProps<Icon>['icon'] | ComponentProps<Icon>
|
|
8
8
|
children?: Snippet
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
class="dropdown-item"
|
|
23
23
|
type="button"
|
|
24
24
|
{...rest}
|
|
25
|
-
>{#if icon}<span class="mr-1"
|
|
25
|
+
>{#if icon}<span class="mr-1 me-1"
|
|
26
26
|
><Icon
|
|
27
27
|
fixedWidth
|
|
28
28
|
{...iconProps}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ComponentProps, Snippet } from
|
|
2
|
-
import type { HTMLButtonAttributes } from
|
|
3
|
-
import Icon from
|
|
1
|
+
import type { ComponentProps, Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
|
+
import Icon from '@isoftdata/svelte-icon';
|
|
4
4
|
interface Props extends Omit<HTMLButtonAttributes, `on:${string}` | `bind:${string}` | `aria-${string}`> {
|
|
5
|
-
icon?: ComponentProps<Icon>[
|
|
5
|
+
icon?: ComponentProps<Icon>['icon'] | ComponentProps<Icon>;
|
|
6
6
|
children?: Snippet;
|
|
7
7
|
}
|
|
8
8
|
declare const DropdownItem: import("svelte").Component<Props, {}, "">;
|
package/package.json
CHANGED
|
@@ -1,60 +1,63 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
2
|
+
"name": "@isoftdata/svelte-context-menu",
|
|
3
|
+
"version": "2.0.2",
|
|
4
|
+
"exports": {
|
|
5
|
+
".": {
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"svelte": "./dist/index.js"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"!dist/**/*.test.*",
|
|
13
|
+
"!dist/**/*.spec.*"
|
|
14
|
+
],
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"svelte": "^5.23.2"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@isoftdata/prettier-config": "^2.0.4",
|
|
20
|
+
"@isoftdata/svelte-bootstrap-version-switcher": "^1.1.2",
|
|
21
|
+
"@isoftdata/svelte-button": "^2.1.0",
|
|
22
|
+
"@isoftdata/svelte-checkbox": "^2.1.1",
|
|
23
|
+
"@sveltejs/adapter-auto": "^6.0.0",
|
|
24
|
+
"@sveltejs/kit": "^2.5.27",
|
|
25
|
+
"@sveltejs/package": "^2.3.7",
|
|
26
|
+
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
|
27
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
28
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
29
|
+
"eslint": "^8.28.0",
|
|
30
|
+
"eslint-config-prettier": "^8.5.0",
|
|
31
|
+
"eslint-plugin-svelte": "^2.45.1",
|
|
32
|
+
"prettier": "^3.1.0",
|
|
33
|
+
"prettier-plugin-svelte": "^3.2.6",
|
|
34
|
+
"publint": "^0.1.9",
|
|
35
|
+
"svelte": "^5.23.1",
|
|
36
|
+
"svelte-check": "^4.0.0",
|
|
37
|
+
"tslib": "^2.4.1",
|
|
38
|
+
"typescript": "^5.5.0",
|
|
39
|
+
"vite": "^6.3.3"
|
|
40
|
+
},
|
|
41
|
+
"svelte": "./dist/index.js",
|
|
42
|
+
"types": "./dist/index.d.ts",
|
|
43
|
+
"type": "module",
|
|
44
|
+
"prettier": "@isoftdata/prettier-config",
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@floating-ui/dom": "^1.5.3",
|
|
47
|
+
"@isoftdata/svelte-icon": "^2.0.0",
|
|
48
|
+
"svelte": "^5.23.2"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"pnpm": "10.x"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"dev": "vite dev",
|
|
55
|
+
"build": "vite build && npm run package",
|
|
56
|
+
"preview": "vite preview",
|
|
57
|
+
"package": "svelte-kit sync && svelte-package && publint",
|
|
58
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
59
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
60
|
+
"lint": "prettier --plugin-search-dir . --check . && eslint .",
|
|
61
|
+
"format": "prettier --plugin-search-dir . --write ."
|
|
62
|
+
}
|
|
63
|
+
}
|