@keenmate/svelte-treeview 0.1.0

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.
@@ -0,0 +1,32 @@
1
+ /** @typedef {typeof __propDef.props} ContextMenuProps */
2
+ /** @typedef {typeof __propDef.events} ContextMenuEvents */
3
+ /** @typedef {typeof __propDef.slots} ContextMenuSlots */
4
+ export default class ContextMenu extends SvelteComponentTyped<{
5
+ onRightClick?: ((e: any, n: any) => Promise<void>) | undefined;
6
+ }, {
7
+ [evt: string]: CustomEvent<any>;
8
+ }, {
9
+ default: {
10
+ node: null;
11
+ };
12
+ }> {
13
+ get onRightClick(): (e: any, n: any) => Promise<void>;
14
+ }
15
+ export type ContextMenuProps = typeof __propDef.props;
16
+ export type ContextMenuEvents = typeof __propDef.events;
17
+ export type ContextMenuSlots = typeof __propDef.slots;
18
+ import { SvelteComponentTyped } from "svelte";
19
+ declare const __propDef: {
20
+ props: {
21
+ onRightClick?: ((e: any, n: any) => Promise<void>) | undefined;
22
+ };
23
+ events: {
24
+ [evt: string]: CustomEvent<any>;
25
+ };
26
+ slots: {
27
+ default: {
28
+ node: null;
29
+ };
30
+ };
31
+ };
32
+ export {};
@@ -0,0 +1,50 @@
1
+ <!-- component from https://svelte.dev/repl/3a33725c3adb4f57b46b597f9dade0c1?version=3.25.0 -->
2
+
3
+ <script>
4
+ // @ts-nocheck
5
+
6
+ import { onMount, setContext, createEventDispatcher } from 'svelte';
7
+ import { fade } from 'svelte/transition';
8
+ import { key } from './menu.js';
9
+
10
+ export let x;
11
+ export let y;
12
+
13
+ // whenever x and y is changed, restrict box to be within bounds
14
+ $: (() => {
15
+ if (!menuEl) return;
16
+
17
+ const rect = menuEl.getBoundingClientRect();
18
+ x = Math.min(window.innerWidth - rect.width, x);
19
+ if (y > window.innerHeight - rect.height) y -= rect.height;
20
+ })(x, y);
21
+
22
+ const dispatch = createEventDispatcher();
23
+
24
+ setContext(key, {
25
+ dispatchClick: () => dispatch('click')
26
+ });
27
+
28
+ let menuEl;
29
+ function onPageClick(e) {
30
+ if (e.target === menuEl || menuEl.contains(e.target)) return;
31
+ dispatch('clickoutside');
32
+ }
33
+ </script>
34
+
35
+ <svelte:body on:click={onPageClick} />
36
+
37
+ <div transition:fade={{ duration: 100 }} bind:this={menuEl} style="top: {y}px; left: {x}px;">
38
+ <slot />
39
+ </div>
40
+
41
+ <style>
42
+ div {
43
+ position: fixed;
44
+ display: grid;
45
+ border: 1px solid #0003;
46
+ box-shadow: 2px 2px 5px 0px #0002;
47
+ background: white;
48
+ z-index: 999;
49
+ }
50
+ </style>
@@ -0,0 +1,35 @@
1
+ /** @typedef {typeof __propDef.props} MenuProps */
2
+ /** @typedef {typeof __propDef.events} MenuEvents */
3
+ /** @typedef {typeof __propDef.slots} MenuSlots */
4
+ export default class Menu extends SvelteComponentTyped<{
5
+ x: any;
6
+ y: any;
7
+ }, {
8
+ click: CustomEvent<any>;
9
+ clickoutside: CustomEvent<any>;
10
+ } & {
11
+ [evt: string]: CustomEvent<any>;
12
+ }, {
13
+ default: {};
14
+ }> {
15
+ }
16
+ export type MenuProps = typeof __propDef.props;
17
+ export type MenuEvents = typeof __propDef.events;
18
+ export type MenuSlots = typeof __propDef.slots;
19
+ import { SvelteComponentTyped } from "svelte";
20
+ declare const __propDef: {
21
+ props: {
22
+ x: any;
23
+ y: any;
24
+ };
25
+ events: {
26
+ click: CustomEvent<any>;
27
+ clickoutside: CustomEvent<any>;
28
+ } & {
29
+ [evt: string]: CustomEvent<any>;
30
+ };
31
+ slots: {
32
+ default: {};
33
+ };
34
+ };
35
+ export {};
@@ -0,0 +1,10 @@
1
+ <style>
2
+ hr {
3
+ border-top: 1px solid #0003;
4
+ width: 100%;
5
+ margin: 2px 0;
6
+ }
7
+ </style>
8
+
9
+
10
+ <hr />
@@ -0,0 +1,23 @@
1
+ /** @typedef {typeof __propDef.props} MenuDividerProps */
2
+ /** @typedef {typeof __propDef.events} MenuDividerEvents */
3
+ /** @typedef {typeof __propDef.slots} MenuDividerSlots */
4
+ export default class MenuDivider extends SvelteComponentTyped<{
5
+ [x: string]: never;
6
+ }, {
7
+ [evt: string]: CustomEvent<any>;
8
+ }, {}> {
9
+ }
10
+ export type MenuDividerProps = typeof __propDef.props;
11
+ export type MenuDividerEvents = typeof __propDef.events;
12
+ export type MenuDividerSlots = typeof __propDef.slots;
13
+ import { SvelteComponentTyped } from "svelte";
14
+ declare const __propDef: {
15
+ props: {
16
+ [x: string]: never;
17
+ };
18
+ events: {
19
+ [evt: string]: CustomEvent<any>;
20
+ };
21
+ slots: {};
22
+ };
23
+ export {};
@@ -0,0 +1,49 @@
1
+ <script>
2
+ // @ts-nocheck
3
+
4
+ import { onMount, getContext } from 'svelte';
5
+ import { key } from './menu.js';
6
+
7
+ export let isDisabled = false;
8
+ export let text = '';
9
+
10
+ import { createEventDispatcher } from 'svelte';
11
+ const dispatch = createEventDispatcher();
12
+
13
+ const { dispatchClick } = getContext(key);
14
+
15
+ const handleClick = (e) => {
16
+ if (isDisabled) return;
17
+
18
+ dispatch('click');
19
+ dispatchClick();
20
+ };
21
+ </script>
22
+
23
+ <div class:disabled={isDisabled} on:click={handleClick}>
24
+ {#if text}
25
+ {text}
26
+ {:else}
27
+ <slot />
28
+ {/if}
29
+ </div>
30
+
31
+ <style>
32
+ div {
33
+ padding: 4px 15px;
34
+ cursor: default;
35
+ font-size: 14px;
36
+ display: flex;
37
+ align-items: center;
38
+ grid-gap: 5px;
39
+ }
40
+ div:hover {
41
+ background: #0002;
42
+ }
43
+ div.disabled {
44
+ color: #0006;
45
+ }
46
+ div.disabled:hover {
47
+ background: white;
48
+ }
49
+ </style>
@@ -0,0 +1,33 @@
1
+ /** @typedef {typeof __propDef.props} MenuOptionProps */
2
+ /** @typedef {typeof __propDef.events} MenuOptionEvents */
3
+ /** @typedef {typeof __propDef.slots} MenuOptionSlots */
4
+ export default class MenuOption extends SvelteComponentTyped<{
5
+ isDisabled?: boolean | undefined;
6
+ text?: string | undefined;
7
+ }, {
8
+ click: CustomEvent<any>;
9
+ } & {
10
+ [evt: string]: CustomEvent<any>;
11
+ }, {
12
+ default: {};
13
+ }> {
14
+ }
15
+ export type MenuOptionProps = typeof __propDef.props;
16
+ export type MenuOptionEvents = typeof __propDef.events;
17
+ export type MenuOptionSlots = typeof __propDef.slots;
18
+ import { SvelteComponentTyped } from "svelte";
19
+ declare const __propDef: {
20
+ props: {
21
+ isDisabled?: boolean | undefined;
22
+ text?: string | undefined;
23
+ };
24
+ events: {
25
+ click: CustomEvent<any>;
26
+ } & {
27
+ [evt: string]: CustomEvent<any>;
28
+ };
29
+ slots: {
30
+ default: {};
31
+ };
32
+ };
33
+ export {};
@@ -0,0 +1 @@
1
+ export const key: {};
@@ -0,0 +1,3 @@
1
+ const key = {};
2
+
3
+ export { key };
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@keenmate/svelte-treeview",
3
+ "version": "0.1.0",
4
+ "scripts": {
5
+ "dev": "vite dev",
6
+ "build": "vite build && npm run package",
7
+ "preview": "vite preview",
8
+ "package": "svelte-kit sync && svelte-package && publint",
9
+ "prepublishOnly": "npm run package",
10
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
11
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
12
+ "lint": "prettier --plugin-search-dir . --check . && eslint .",
13
+ "format": "prettier --plugin-search-dir . --write ."
14
+ },
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "svelte": "./dist/index.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "!dist/**/*.test.*",
24
+ "!dist/**/*.spec.*"
25
+ ],
26
+ "peerDependencies": {
27
+ "svelte": "^3.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "@sveltejs/adapter-auto": "^2.0.0",
31
+ "@sveltejs/kit": "^1.20.4",
32
+ "@sveltejs/package": "^2.0.0",
33
+ "@types/marked": "^5.0.0",
34
+ "@types/node": "^20.3.3",
35
+ "@typescript-eslint/eslint-plugin": "^5.45.0",
36
+ "@typescript-eslint/parser": "^5.45.0",
37
+ "eslint": "^8.28.0",
38
+ "eslint-config-prettier": "^8.5.0",
39
+ "eslint-plugin-svelte": "^2.30.0",
40
+ "prettier": "^2.8.0",
41
+ "prettier-plugin-svelte": "^2.10.1",
42
+ "publint": "^0.1.9",
43
+ "rollup-plugin-string": "^3.0.0",
44
+ "sass": "^1.49.0",
45
+ "svelte": "^4.0.0",
46
+ "svelte-check": "^3.4.3",
47
+ "svelte-preprocess": "^5.0.4",
48
+ "tslib": "^2.4.1",
49
+ "typescript": "^5.0.0",
50
+ "vite": "^4.3.6",
51
+ "@keenmate/svelte-adminlte": "^0.3.20",
52
+ "@keenmate/svelte-treeview": "^0.0.1",
53
+ "marked": "^5.1.0",
54
+ "svelte-multiselect": "github:KeenMate/svelte-multiselect"
55
+ },
56
+ "svelte": "./dist/index.js",
57
+ "types": "./dist/index.d.ts",
58
+ "type": "module",
59
+ "dependencies": {
60
+ "lodash.unionby": "^4.8.0",
61
+ "lodash.uniq": "^4.5.0"
62
+ }
63
+ }