lau-ecom-design-system 1.0.20 β 1.0.21
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/lau-ecom-design-system.esm.css +2 -0
- package/dist/lau-ecom-design-system.esm.js +862 -460
- package/dist/lau-ecom-design-system.min.css +2 -0
- package/dist/lau-ecom-design-system.min.js +1 -1
- package/dist/lau-ecom-design-system.ssr.css +2 -0
- package/dist/lau-ecom-design-system.ssr.js +821 -416
- package/dist/style.css +171 -58
- package/package.json +3 -2
- package/src/components/LauEcomDropdown/LauEcomDropdown.vue +10 -5
- package/src/components/LauEcomInput/LauEcomInput.vue +1 -1
- package/src/components/LauEcomInput2/LauEcomInput2.vue +207 -0
- package/src/components/LauEcomInputSearch/LauEcomInputSearch.vue +244 -0
@@ -0,0 +1,244 @@
|
|
1
|
+
<script lang="ts" setup>
|
2
|
+
import { ref, computed, onMounted, onBeforeUnmount, watch, nextTick } from "vue";
|
3
|
+
import {
|
4
|
+
LauEcomUpcIconCheck as LauEcomUpcIconSearch,
|
5
|
+
LauEcomCoreIconNavClose as LauEcomUpcIconClose,
|
6
|
+
} from "../LauEcomIcon";
|
7
|
+
|
8
|
+
// Log de versiΓ³n del componente
|
9
|
+
console.log('π InputSearch Version: 1.0.20 - Debug Mode');
|
10
|
+
|
11
|
+
interface Props {
|
12
|
+
placeholder?: string;
|
13
|
+
isDisabled?: boolean;
|
14
|
+
modelValue?: string;
|
15
|
+
forceClose?: boolean;
|
16
|
+
}
|
17
|
+
|
18
|
+
const props = withDefaults(defineProps<Props>(), {
|
19
|
+
placeholder: "Quiero aprender...",
|
20
|
+
isDisabled: false,
|
21
|
+
modelValue: "",
|
22
|
+
forceClose: false,
|
23
|
+
});
|
24
|
+
|
25
|
+
// Log de props iniciales
|
26
|
+
console.log('π InputSearch Props:', {
|
27
|
+
placeholder: props.placeholder,
|
28
|
+
isDisabled: props.isDisabled,
|
29
|
+
modelValue: props.modelValue,
|
30
|
+
forceClose: props.forceClose
|
31
|
+
});
|
32
|
+
|
33
|
+
const emit = defineEmits({
|
34
|
+
"update:modelValue": (value: string) => true,
|
35
|
+
"search": (value: string) => true,
|
36
|
+
});
|
37
|
+
|
38
|
+
const searchQuery = ref(props.modelValue);
|
39
|
+
const isExpanded = ref(false);
|
40
|
+
const showOverlay = ref(false);
|
41
|
+
|
42
|
+
const handleSearch = () => {
|
43
|
+
console.log('π Search triggered:', {
|
44
|
+
query: searchQuery.value,
|
45
|
+
isExpanded: isExpanded.value,
|
46
|
+
showOverlay: showOverlay.value
|
47
|
+
});
|
48
|
+
|
49
|
+
if (searchQuery.value && searchQuery.value.trim()) {
|
50
|
+
emit("search", searchQuery.value);
|
51
|
+
emit("update:modelValue", searchQuery.value);
|
52
|
+
closeSearch();
|
53
|
+
}
|
54
|
+
};
|
55
|
+
|
56
|
+
const handleInput = () => {
|
57
|
+
console.log('π Input changed:', {
|
58
|
+
value: searchQuery.value,
|
59
|
+
length: searchQuery.value.length,
|
60
|
+
isExpanded: isExpanded.value
|
61
|
+
});
|
62
|
+
emit("update:modelValue", searchQuery.value);
|
63
|
+
};
|
64
|
+
|
65
|
+
const clearSearch = () => {
|
66
|
+
console.log('π Clear search triggered');
|
67
|
+
searchQuery.value = "";
|
68
|
+
emit("update:modelValue", "");
|
69
|
+
};
|
70
|
+
|
71
|
+
const closeSearch = () => {
|
72
|
+
console.log('π Close search triggered');
|
73
|
+
showOverlay.value = false;
|
74
|
+
setTimeout(() => {
|
75
|
+
console.log('π Closing search after timeout');
|
76
|
+
isExpanded.value = false;
|
77
|
+
}, 300);
|
78
|
+
};
|
79
|
+
|
80
|
+
const handleFocus = () => {
|
81
|
+
console.log('π Focus triggered:', {
|
82
|
+
currentValue: searchQuery.value,
|
83
|
+
wasExpanded: isExpanded.value
|
84
|
+
});
|
85
|
+
isExpanded.value = true;
|
86
|
+
showOverlay.value = true;
|
87
|
+
};
|
88
|
+
|
89
|
+
const containerClasses = computed(() => {
|
90
|
+
const classes = [
|
91
|
+
"dsEcom-transition-transform dsEcom-duration-300 dsEcom-ease-in-out",
|
92
|
+
{
|
93
|
+
"dsEcom-relative dsEcom-w-[250px] md:dsEcom-w-[350px]": !isExpanded.value
|
94
|
+
}
|
95
|
+
];
|
96
|
+
console.log('π Container classes updated:', { isExpanded: isExpanded.value });
|
97
|
+
return classes;
|
98
|
+
});
|
99
|
+
|
100
|
+
const overlayClasses = computed(() => [
|
101
|
+
"dsEcom-fixed dsEcom-inset-0 dsEcom-bg-black dsEcom-transition-opacity dsEcom-duration-300 dsEcom-ease-in-out dsEcom-z-40",
|
102
|
+
{
|
103
|
+
"dsEcom-opacity-50": showOverlay.value,
|
104
|
+
"dsEcom-opacity-0 dsEcom-pointer-events-none": !showOverlay.value
|
105
|
+
}
|
106
|
+
]);
|
107
|
+
|
108
|
+
const originalContainer = ref<HTMLElement | null>(null);
|
109
|
+
const expandedContainer = ref<HTMLElement | null>(null);
|
110
|
+
|
111
|
+
const updateExpandedPosition = () => {
|
112
|
+
if (originalContainer.value && expandedContainer.value) {
|
113
|
+
const rect = originalContainer.value.getBoundingClientRect();
|
114
|
+
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
115
|
+
expandedContainer.value.style.top = `${rect.top + scrollTop}px`;
|
116
|
+
console.log('π Updated expanded position:', { top: rect.top + scrollTop });
|
117
|
+
}
|
118
|
+
};
|
119
|
+
|
120
|
+
onMounted(() => {
|
121
|
+
console.log('π Component mounted');
|
122
|
+
window.addEventListener('resize', updateExpandedPosition);
|
123
|
+
});
|
124
|
+
|
125
|
+
onBeforeUnmount(() => {
|
126
|
+
console.log('π Component will unmount');
|
127
|
+
window.removeEventListener('resize', updateExpandedPosition);
|
128
|
+
});
|
129
|
+
|
130
|
+
watch(isExpanded, (newValue) => {
|
131
|
+
console.log('π isExpanded changed:', {
|
132
|
+
newValue,
|
133
|
+
searchQuery: searchQuery.value,
|
134
|
+
showOverlay: showOverlay.value
|
135
|
+
});
|
136
|
+
if (newValue) {
|
137
|
+
nextTick(updateExpandedPosition);
|
138
|
+
}
|
139
|
+
});
|
140
|
+
|
141
|
+
watch(() => props.forceClose, (newValue) => {
|
142
|
+
console.log('π forceClose prop changed:', newValue);
|
143
|
+
if (newValue) {
|
144
|
+
closeSearch();
|
145
|
+
}
|
146
|
+
});
|
147
|
+
|
148
|
+
watch(() => props.modelValue, (newValue) => {
|
149
|
+
console.log('π modelValue prop changed:', {
|
150
|
+
newValue,
|
151
|
+
currentSearchQuery: searchQuery.value
|
152
|
+
});
|
153
|
+
if (newValue !== searchQuery.value) {
|
154
|
+
searchQuery.value = newValue;
|
155
|
+
}
|
156
|
+
});
|
157
|
+
</script>
|
158
|
+
|
159
|
+
<template>
|
160
|
+
<div class="dsEcom-relative">
|
161
|
+
<div
|
162
|
+
:class="containerClasses"
|
163
|
+
ref="originalContainer"
|
164
|
+
>
|
165
|
+
<input
|
166
|
+
v-model="searchQuery"
|
167
|
+
type="text"
|
168
|
+
:placeholder="placeholder"
|
169
|
+
:disabled="isDisabled"
|
170
|
+
class="lau-ecom-input dsEcom-border dsEcom-border-neutral-80 dsEcom-rounded-lg dsEcom-px-4 dsEcom-h-10 dsEcom-w-full dsEcom-focus:outline-none dsEcom-focus:ring-2 dsEcom-focus:ring-primary-60"
|
171
|
+
@focus="handleFocus"
|
172
|
+
@input="handleInput"
|
173
|
+
@keyup.enter="handleSearch"
|
174
|
+
:class="{ 'dsEcom-invisible': isExpanded }"
|
175
|
+
/>
|
176
|
+
<button
|
177
|
+
v-if="searchQuery.length >= 3 && !isExpanded"
|
178
|
+
@click="handleSearch"
|
179
|
+
class="dsEcom-absolute dsEcom-right-2 dsEcom-top-1/2 -dsEcom-translate-y-1/2 dsEcom-bg-primary-60 hover:dsEcom-bg-primary-70 dsEcom-text-white dsEcom-p-2 dsEcom-rounded-lg dsEcom-transition-all dsEcom-duration-300"
|
180
|
+
>
|
181
|
+
<LauEcomUpcIconSearch width="20" height="20" />
|
182
|
+
</button>
|
183
|
+
</div>
|
184
|
+
|
185
|
+
<!-- Overlay -->
|
186
|
+
<div
|
187
|
+
:class="overlayClasses"
|
188
|
+
@click="closeSearch"
|
189
|
+
></div>
|
190
|
+
|
191
|
+
<!-- VersiΓ³n expandida -->
|
192
|
+
<div
|
193
|
+
v-show="isExpanded"
|
194
|
+
class="dsEcom-fixed dsEcom-w-[656px] dsEcom-left-1/2 dsEcom-transform -dsEcom-translate-x-1/2 dsEcom-z-50"
|
195
|
+
:style="{ top: isExpanded ? `${originalContainer?.getBoundingClientRect().top}px` : '0' }"
|
196
|
+
ref="expandedContainer"
|
197
|
+
>
|
198
|
+
<div class="dsEcom-relative">
|
199
|
+
<input
|
200
|
+
v-model="searchQuery"
|
201
|
+
type="text"
|
202
|
+
:placeholder="placeholder"
|
203
|
+
:disabled="isDisabled"
|
204
|
+
class="lau-ecom-input dsEcom-border dsEcom-border-neutral-80 dsEcom-rounded-lg dsEcom-px-4 dsEcom-h-10 dsEcom-w-full dsEcom-focus:outline-none dsEcom-focus:ring-2 dsEcom-focus:ring-primary-60 dsEcom-bg-white"
|
205
|
+
@input="handleInput"
|
206
|
+
@keyup.enter="handleSearch"
|
207
|
+
autofocus
|
208
|
+
/>
|
209
|
+
|
210
|
+
<div class="dsEcom-absolute dsEcom-right-2 dsEcom-top-1/2 -dsEcom-translate-y-1/2 dsEcom-flex dsEcom-gap-2">
|
211
|
+
<button
|
212
|
+
v-if="searchQuery.length >= 3"
|
213
|
+
@click="clearSearch"
|
214
|
+
class="dsEcom-text-neutral-100 hover:dsEcom-text-neutral-80 dsEcom-transition-all dsEcom-duration-300"
|
215
|
+
>
|
216
|
+
<LauEcomUpcIconClose width="16" height="16" />
|
217
|
+
</button>
|
218
|
+
|
219
|
+
<button
|
220
|
+
v-if="searchQuery.length >= 3"
|
221
|
+
@click="handleSearch"
|
222
|
+
class="dsEcom-bg-primary-60 hover:dsEcom-bg-primary-70 dsEcom-text-white dsEcom-p-2 dsEcom-rounded-lg dsEcom-transition-all dsEcom-duration-300"
|
223
|
+
>
|
224
|
+
<LauEcomUpcIconSearch width="20" height="20" />
|
225
|
+
</button>
|
226
|
+
</div>
|
227
|
+
</div>
|
228
|
+
</div>
|
229
|
+
</div>
|
230
|
+
</template>
|
231
|
+
|
232
|
+
<style scoped>
|
233
|
+
.lau-ecom-input {
|
234
|
+
transition: all 0.3s ease-in-out;
|
235
|
+
}
|
236
|
+
|
237
|
+
.dsEcom-transform-gpu {
|
238
|
+
transform: translateZ(0);
|
239
|
+
backface-visibility: hidden;
|
240
|
+
perspective: 1000px;
|
241
|
+
}
|
242
|
+
</style>
|
243
|
+
|
244
|
+
|