@valerius_petrini/corekit-ui 0.1.42 → 0.1.44
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.
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
value = $bindable(),
|
|
11
11
|
onfocus = undefined,
|
|
12
12
|
onblur = undefined,
|
|
13
|
+
isTextArea = false,
|
|
13
14
|
validInputRegex = undefined,
|
|
14
15
|
id = crypto.randomUUID(),
|
|
15
16
|
...restProps
|
|
@@ -25,12 +26,16 @@
|
|
|
25
26
|
let defaultLabelClass = "block text-sub-text rounded-md text-sm font-medium mb-1 absolute transition-all duration-100 pointer-events-none";
|
|
26
27
|
let defaultDivClass = "relative";
|
|
27
28
|
|
|
28
|
-
let originalLabelClass = "left-2
|
|
29
|
+
let originalLabelClass = "left-2 z-0";
|
|
30
|
+
let originalLabelClassInput = "top-1/2 transform -translate-y-1/2";
|
|
31
|
+
let originalLabelClassTextArea = "top-2";
|
|
29
32
|
let selectedLabelClass = "left-2 z-30 top-0.5 text-[10px]";
|
|
30
33
|
|
|
31
34
|
let invalidClass = "border border-red-500 focus:ring-red-500";
|
|
32
35
|
|
|
33
|
-
let
|
|
36
|
+
let labelClassFull = $derived(twMerge(isTextArea ? originalLabelClassTextArea : originalLabelClassInput, originalLabelClass));
|
|
37
|
+
|
|
38
|
+
let combinedLabelClass = $derived(twMerge(defaultLabelClass, isFocused || hasContent ? selectedLabelClass : labelClassFull, labelClass));
|
|
34
39
|
let combinedClass = $derived(twMerge(defaultClass, className, isValid ? "" : invalidClass));
|
|
35
40
|
let combinedDivClass = $derived(twMerge(defaultDivClass, divClass));
|
|
36
41
|
|
|
@@ -50,12 +55,23 @@
|
|
|
50
55
|
<label for={id} class={combinedLabelClass}>
|
|
51
56
|
{@render children?.()}
|
|
52
57
|
</label>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
{#if isTextArea}
|
|
59
|
+
<textarea
|
|
60
|
+
{id}
|
|
61
|
+
bind:value={value}
|
|
62
|
+
onfocus={handleFocus}
|
|
63
|
+
onblur={handleBlur}
|
|
64
|
+
class={combinedClass}
|
|
65
|
+
{...restProps}
|
|
66
|
+
></textarea>
|
|
67
|
+
{:else}
|
|
68
|
+
<input
|
|
69
|
+
{id}
|
|
70
|
+
bind:value={value}
|
|
71
|
+
onfocus={handleFocus}
|
|
72
|
+
onblur={handleBlur}
|
|
73
|
+
class={combinedClass}
|
|
74
|
+
{...restProps}
|
|
75
|
+
/>
|
|
76
|
+
{/if}
|
|
61
77
|
</div>
|
|
@@ -3,8 +3,8 @@ export interface FloatingSelectProps {
|
|
|
3
3
|
class?: string;
|
|
4
4
|
divClass?: string;
|
|
5
5
|
optionClass?: string;
|
|
6
|
-
value?:
|
|
7
|
-
options: { value:
|
|
6
|
+
value?: any;
|
|
7
|
+
options: { value: any; label: string }[];
|
|
8
8
|
id?: `${string}-${string}-${string}-${string}-${string}`;
|
|
9
9
|
[key: string]: any;
|
|
10
10
|
};
|