@intechstudio/grid-uikit 1.20241017.2206 → 1.20241122.1635
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/dist/MeltCombo.svelte +137 -0
- package/dist/MeltCombo.svelte.d.ts +31 -0
- package/dist/MeltRadio.svelte.d.ts +2 -0
- package/dist/Tree.svelte +58 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +3 -2
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import {
|
|
3
|
+
createCombobox,
|
|
4
|
+
melt
|
|
5
|
+
} from "@melt-ui/svelte";
|
|
6
|
+
export let value;
|
|
7
|
+
export let size = "auto";
|
|
8
|
+
export let suggestions = [];
|
|
9
|
+
export let placeholder = "";
|
|
10
|
+
export let validator = (value2) => {
|
|
11
|
+
return true;
|
|
12
|
+
};
|
|
13
|
+
export let disabled = false;
|
|
14
|
+
export let preProcessor = (value2) => {
|
|
15
|
+
return value2;
|
|
16
|
+
};
|
|
17
|
+
export let postProcessor = (value2) => {
|
|
18
|
+
return value2;
|
|
19
|
+
};
|
|
20
|
+
export let title = "";
|
|
21
|
+
const toOption = (option2) => ({
|
|
22
|
+
value: option2,
|
|
23
|
+
label: option2.info
|
|
24
|
+
});
|
|
25
|
+
const dispatch = createEventDispatcher();
|
|
26
|
+
let isError = false;
|
|
27
|
+
let infoValue = "";
|
|
28
|
+
let oldValue = void 0;
|
|
29
|
+
const {
|
|
30
|
+
elements: { menu, input, option, label },
|
|
31
|
+
states: { open, inputValue, selected },
|
|
32
|
+
helpers: { isSelected }
|
|
33
|
+
} = createCombobox({
|
|
34
|
+
forceVisible: true
|
|
35
|
+
});
|
|
36
|
+
$:
|
|
37
|
+
handleValueChange(value);
|
|
38
|
+
$:
|
|
39
|
+
handleSelectionChange($selected?.value);
|
|
40
|
+
$:
|
|
41
|
+
handleInputChange($inputValue);
|
|
42
|
+
function handleValueChange(value2) {
|
|
43
|
+
if ($inputValue === value2 || !value2) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
inputValue.set(preProcessor(value2));
|
|
47
|
+
}
|
|
48
|
+
function handleSelectionChange(option2) {
|
|
49
|
+
if (!option2) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
handleInputChange(option2.value);
|
|
53
|
+
handleChange();
|
|
54
|
+
}
|
|
55
|
+
function handleInputChange(input2) {
|
|
56
|
+
infoValue = suggestions.find((s) => String(s.value).trim() == String(input2).trim())?.info || "";
|
|
57
|
+
isError = !validator($inputValue);
|
|
58
|
+
if (oldValue === void 0) {
|
|
59
|
+
oldValue = value;
|
|
60
|
+
}
|
|
61
|
+
if (input2 === value) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
value = input2;
|
|
65
|
+
inputValue.set(value);
|
|
66
|
+
dispatch("validator", { isError });
|
|
67
|
+
dispatch("input", postProcessor(input2));
|
|
68
|
+
}
|
|
69
|
+
function handleChange() {
|
|
70
|
+
if (oldValue !== void 0 && oldValue !== value) {
|
|
71
|
+
oldValue = void 0;
|
|
72
|
+
dispatch("change", postProcessor($inputValue));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<div class="flex flex-col relative" class:flex-grow={size === "full"}>
|
|
78
|
+
<!-- svelte-ignore a11y-label-has-associated-control -->
|
|
79
|
+
<label
|
|
80
|
+
use:melt={$label}
|
|
81
|
+
class="text-white text-sm pb-1 truncate items-center"
|
|
82
|
+
class:hidden={label.length === 0}
|
|
83
|
+
>
|
|
84
|
+
{title}
|
|
85
|
+
</label>
|
|
86
|
+
<input
|
|
87
|
+
type="text"
|
|
88
|
+
use:melt={$input}
|
|
89
|
+
on:change={handleChange}
|
|
90
|
+
class="w-full flex flex-row border mb-1 {isError && !disabled
|
|
91
|
+
? 'border-error'
|
|
92
|
+
: 'border-black'} p-2 {disabled
|
|
93
|
+
? 'bg-black/20 text-white/40'
|
|
94
|
+
: 'bg-transparent text-white'}"
|
|
95
|
+
{placeholder}
|
|
96
|
+
{disabled}
|
|
97
|
+
/>
|
|
98
|
+
{#if $open && !disabled && suggestions.length > 0}
|
|
99
|
+
<div {...$menu} use:menu class="menu">
|
|
100
|
+
{#each suggestions as suggestion}
|
|
101
|
+
<div
|
|
102
|
+
{...$option(toOption(suggestion))}
|
|
103
|
+
use:option
|
|
104
|
+
class="cursor-pointer truncate hover:bg-white/40 p-2 hover:text-white {$isSelected(
|
|
105
|
+
suggestion.value,
|
|
106
|
+
)
|
|
107
|
+
? 'bg-white/10'
|
|
108
|
+
: ' '}"
|
|
109
|
+
>
|
|
110
|
+
{suggestion.info}
|
|
111
|
+
</div>
|
|
112
|
+
{/each}
|
|
113
|
+
</div>
|
|
114
|
+
{/if}
|
|
115
|
+
|
|
116
|
+
<div class="text-white/60 text-sm truncate">
|
|
117
|
+
{infoValue}
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
<style>
|
|
122
|
+
.menu {
|
|
123
|
+
z-index: 40;
|
|
124
|
+
max-height: 8rem;
|
|
125
|
+
overflow-y: auto;
|
|
126
|
+
border-radius: 0.25rem;
|
|
127
|
+
border-width: 1px;
|
|
128
|
+
border-color: rgb(255 255 255 / 0.5);
|
|
129
|
+
--tw-bg-opacity: 1;
|
|
130
|
+
background-color: rgb(23 23 23 / var(--tw-bg-opacity));
|
|
131
|
+
color: rgb(255 255 255 / 0.8);
|
|
132
|
+
width: -moz-fit-content !important;
|
|
133
|
+
width: fit-content !important;
|
|
134
|
+
min-width: 8% !important;
|
|
135
|
+
max-width: 13% !important
|
|
136
|
+
}
|
|
137
|
+
</style>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
value: any;
|
|
5
|
+
size?: "auto" | "full";
|
|
6
|
+
suggestions?: Array<{
|
|
7
|
+
info: string;
|
|
8
|
+
value: any;
|
|
9
|
+
}>;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
validator?: (value: string) => boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
preProcessor?: (value: string) => string;
|
|
14
|
+
postProcessor?: (value: string) => string;
|
|
15
|
+
title?: string;
|
|
16
|
+
};
|
|
17
|
+
events: {
|
|
18
|
+
validator: CustomEvent<any>;
|
|
19
|
+
input: CustomEvent<any>;
|
|
20
|
+
change: CustomEvent<any>;
|
|
21
|
+
} & {
|
|
22
|
+
[evt: string]: CustomEvent<any>;
|
|
23
|
+
};
|
|
24
|
+
slots: {};
|
|
25
|
+
};
|
|
26
|
+
export type MeltComboProps = typeof __propDef.props;
|
|
27
|
+
export type MeltComboEvents = typeof __propDef.events;
|
|
28
|
+
export type MeltComboSlots = typeof __propDef.slots;
|
|
29
|
+
export default class MeltCombo extends SvelteComponent<MeltComboProps, MeltComboEvents, MeltComboSlots> {
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -19,6 +19,8 @@ declare const __propDef: {
|
|
|
19
19
|
update: (updater: import("svelte/store").Updater<string>, sideEffect?: ((newValue: string) => void) | undefined) => void;
|
|
20
20
|
set: (this: void, value: string) => void;
|
|
21
21
|
subscribe(this: void, run: import("svelte/store").Subscriber<string>, invalidate?: import("svelte/store").Invalidator<string> | undefined): import("svelte/store").Unsubscriber;
|
|
22
|
+
get: () => string;
|
|
23
|
+
destroy?: (() => void) | undefined;
|
|
22
24
|
};
|
|
23
25
|
};
|
|
24
26
|
};
|
package/dist/Tree.svelte
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<script>import {} from "@melt-ui/svelte";
|
|
2
|
+
import { getContext } from "svelte";
|
|
3
|
+
export let treeItems = [];
|
|
4
|
+
export let level = 0;
|
|
5
|
+
export let toggleMainLevels = true;
|
|
6
|
+
const {
|
|
7
|
+
elements: { item, group },
|
|
8
|
+
helpers: { isExpanded },
|
|
9
|
+
states: { expanded }
|
|
10
|
+
} = getContext("tree");
|
|
11
|
+
function toggleExpand(id, level2, value) {
|
|
12
|
+
if (!toggleMainLevels) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (level2 === 0 && value) {
|
|
16
|
+
expanded.set([id]);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
{#each treeItems as child}
|
|
22
|
+
<button
|
|
23
|
+
type="button"
|
|
24
|
+
{...$item({ id: child.id, hasChildren: true })}
|
|
25
|
+
use:item
|
|
26
|
+
on:click={() => toggleExpand(child.id, level, $isExpanded(child.id))}
|
|
27
|
+
class="flex items-center w-full"
|
|
28
|
+
>
|
|
29
|
+
<slot name="folder" {level} {child} isExpanded={$isExpanded(child.id)} />
|
|
30
|
+
</button>
|
|
31
|
+
|
|
32
|
+
{#if $isExpanded(child.id)}
|
|
33
|
+
<div
|
|
34
|
+
class="flex flex-col"
|
|
35
|
+
class:max-h-full={level === 0}
|
|
36
|
+
class:overflow-y-scroll={level === 0}
|
|
37
|
+
class:pr-1={level === 0}
|
|
38
|
+
>
|
|
39
|
+
{#if child.children && child.children.length > 0}
|
|
40
|
+
<div {...$group({ id: child.id })} use:group class="pl-4">
|
|
41
|
+
<svelte:self treeItems={child.children} level={level + 1}>
|
|
42
|
+
<svelte:fragment slot="folder" let:level let:child let:isExpanded>
|
|
43
|
+
<slot name="folder" {level} {child} {isExpanded} />
|
|
44
|
+
</svelte:fragment>
|
|
45
|
+
|
|
46
|
+
<svelte:fragment slot="file" let:item>
|
|
47
|
+
<slot name="file" {item} />
|
|
48
|
+
</svelte:fragment>
|
|
49
|
+
</svelte:self>
|
|
50
|
+
</div>
|
|
51
|
+
{/if}
|
|
52
|
+
|
|
53
|
+
{#each child.items as item (item.id)}
|
|
54
|
+
<slot name="file" {item} />
|
|
55
|
+
{/each}
|
|
56
|
+
</div>
|
|
57
|
+
{/if}
|
|
58
|
+
{/each}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,3 +15,5 @@ export { default as AtomicInput } from "./AtomicInput.svelte";
|
|
|
15
15
|
export { default as AtomicSuggestions } from "./AtomicSuggestions.svelte";
|
|
16
16
|
export { contextMenu, contextTarget } from "./context-target";
|
|
17
17
|
export { default as SvgIcon } from "./SvgIcon.svelte";
|
|
18
|
+
export { default as Tree } from "./Tree.svelte";
|
|
19
|
+
export { default as MeltCombo } from "./MeltCombo.svelte";
|
package/dist/index.js
CHANGED
|
@@ -15,3 +15,5 @@ export { default as AtomicInput } from "./AtomicInput.svelte";
|
|
|
15
15
|
export { default as AtomicSuggestions } from "./AtomicSuggestions.svelte";
|
|
16
16
|
export { contextMenu, contextTarget } from "./context-target";
|
|
17
17
|
export { default as SvgIcon } from "./SvgIcon.svelte";
|
|
18
|
+
export { default as Tree } from "./Tree.svelte";
|
|
19
|
+
export { default as MeltCombo } from "./MeltCombo.svelte";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intechstudio/grid-uikit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20241122.1635",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite",
|
|
6
6
|
"build": "vite build",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"!dist/**/*.spec.*"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@melt-ui/
|
|
28
|
+
"@melt-ui/pp": "^0.3.2",
|
|
29
|
+
"@melt-ui/svelte": "^0.84.0",
|
|
29
30
|
"svelte": "^4.2.12",
|
|
30
31
|
"svelte-easy-popover": "^1.0.0"
|
|
31
32
|
},
|