@valerius_petrini/corekit-ui 0.1.41 → 0.1.42
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.
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import type { FloatingSelectProps } from "../types/FloatingSelect.js";
|
|
2
3
|
import { twMerge } from "tailwind-merge";
|
|
3
4
|
|
|
4
5
|
let {
|
|
5
6
|
children = undefined,
|
|
6
|
-
class: className = "",
|
|
7
|
+
class: className = "",
|
|
8
|
+
divName = "",
|
|
9
|
+
optionClass = "",
|
|
10
|
+
value = $bindable(),
|
|
7
11
|
options = [],
|
|
8
12
|
id = crypto.randomUUID(),
|
|
9
13
|
...restProps
|
|
10
|
-
} = $props();
|
|
14
|
+
}: FloatingSelectProps = $props();
|
|
11
15
|
|
|
12
16
|
let defaultSelectClass = "cursor-pointer bg-form-input-background text-main-text z-20 w-full rounded px-1 pt-4 pb-1 text-xs outline-none focus:ring-2 focus:ring-blue-500 transition-all";
|
|
13
17
|
let defaultLabelClass = "block text-sub-text rounded-md text-sm font-medium mb-1 absolute transition-all duration-100 pointer-events-none";
|
|
@@ -18,15 +22,18 @@
|
|
|
18
22
|
|
|
19
23
|
let combinedLabelClass = $derived(twMerge(defaultLabelClass, selectedLabelClass, className));
|
|
20
24
|
let combinedSelectClass = $derived(twMerge(defaultSelectClass, className));
|
|
25
|
+
let combinedDivClass = $derived(twMerge(defaultDivClass, divName));
|
|
21
26
|
</script>
|
|
22
27
|
|
|
23
|
-
<div class={
|
|
28
|
+
<div class={combinedDivClass}>
|
|
24
29
|
<label for={id} class={combinedLabelClass}>
|
|
25
30
|
{@render children?.()}
|
|
26
31
|
</label>
|
|
27
|
-
<select {id} class={combinedSelectClass} {...restProps}>
|
|
32
|
+
<select {id} class={combinedSelectClass} {...restProps} bind:value={value}>
|
|
28
33
|
{#each options as option}
|
|
29
|
-
<option value={option.value}
|
|
34
|
+
<option value={option.value} class={optionClass}>
|
|
35
|
+
{option.label}
|
|
36
|
+
</option>
|
|
30
37
|
{/each}
|
|
31
38
|
</select>
|
|
32
39
|
</div>
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
class?: string;
|
|
4
|
-
options?: any[];
|
|
5
|
-
id?: any;
|
|
6
|
-
} & Record<string, any>, {}, "">;
|
|
1
|
+
import type { FloatingSelectProps } from "../types/FloatingSelect.js";
|
|
2
|
+
declare const FloatingSelect: import("svelte").Component<FloatingSelectProps, {}, "value">;
|
|
7
3
|
type FloatingSelect = ReturnType<typeof FloatingSelect>;
|
|
8
4
|
export default FloatingSelect;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface FloatingSelectProps {
|
|
2
|
+
children?: any;
|
|
3
|
+
class?: string;
|
|
4
|
+
divClass?: string;
|
|
5
|
+
optionClass?: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
options: { value: string; label: string }[];
|
|
8
|
+
id?: `${string}-${string}-${string}-${string}-${string}`;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|