@usssa/component-library 1.0.0-alpha.218 → 1.0.0-alpha.219
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/README.md +1 -1
- package/package.json +1 -1
- package/src/components/core/UInputAddressLookup.vue +131 -110
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed, onMounted, ref, watch } from 'vue'
|
|
2
|
+
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
3
3
|
import UInputTextStd from './UInputTextStd.vue'
|
|
4
4
|
import UTooltip from './UTooltip.vue'
|
|
5
5
|
|
|
@@ -177,13 +177,28 @@ const onClick = (item) => {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
const onMenuShow = () => {
|
|
180
|
-
|
|
181
|
-
inputRef.value?.$el.querySelector('.q-field__control') ||
|
|
182
|
-
inputRef.value?.$el
|
|
183
|
-
menuWidth.value = `${el?.offsetWidth || 0}px`
|
|
180
|
+
updateMenuWidth()
|
|
184
181
|
resultsMenuShowing.value = true
|
|
185
182
|
}
|
|
186
183
|
|
|
184
|
+
onMounted(async () => {
|
|
185
|
+
const { AutocompleteSessionToken, AutocompleteSuggestion } =
|
|
186
|
+
await google.maps.importLibrary('places')
|
|
187
|
+
|
|
188
|
+
sessionToken = new AutocompleteSessionToken()
|
|
189
|
+
autocompleteSuggestion = AutocompleteSuggestion
|
|
190
|
+
window.addEventListener('resize', updateMenuWidth)
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
const onResize = ({ width }) => {
|
|
194
|
+
resultsMenuShowing.value = false
|
|
195
|
+
updateMenuWidth()
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
onUnmounted(() => {
|
|
199
|
+
window.removeEventListener('resize', updateMenuWidth)
|
|
200
|
+
})
|
|
201
|
+
|
|
187
202
|
const parseAddressComponents = (addressComponents) => {
|
|
188
203
|
const address = {}
|
|
189
204
|
for (const component of addressComponents) {
|
|
@@ -205,13 +220,12 @@ const parseAddressComponents = (addressComponents) => {
|
|
|
205
220
|
return address
|
|
206
221
|
}
|
|
207
222
|
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
})
|
|
223
|
+
const updateMenuWidth = () => {
|
|
224
|
+
const el =
|
|
225
|
+
inputRef.value?.$el.querySelector('.q-field__control') ||
|
|
226
|
+
inputRef.value?.$el
|
|
227
|
+
menuWidth.value = `${el?.offsetWidth || 0}px`
|
|
228
|
+
}
|
|
215
229
|
|
|
216
230
|
watch(modelValue, async (value) => {
|
|
217
231
|
if (value) {
|
|
@@ -261,108 +275,115 @@ watch(modelValue, async (value) => {
|
|
|
261
275
|
/>
|
|
262
276
|
</q-icon>
|
|
263
277
|
</label>
|
|
264
|
-
<
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
while the manual width styling enforces a specific width for visual consistency. -->
|
|
286
|
-
<q-menu
|
|
287
|
-
v-model="resultsMenuShowing"
|
|
288
|
-
fit
|
|
289
|
-
no-focus
|
|
290
|
-
ref="resultsMenuRef"
|
|
291
|
-
:style="{ width: menuWidth }"
|
|
292
|
-
@hide="resultsMenuShowing = false"
|
|
293
|
-
@show="onMenuShow"
|
|
278
|
+
<div ref="inputWrapper">
|
|
279
|
+
<q-input
|
|
280
|
+
v-bind="$attrs"
|
|
281
|
+
v-model="modelValue"
|
|
282
|
+
:class="`u-input field-${size} ${leftBorderRadius}`"
|
|
283
|
+
:borderless="borderless"
|
|
284
|
+
:bottom-slots="!!hintText"
|
|
285
|
+
:debounce="500"
|
|
286
|
+
:disable="disable"
|
|
287
|
+
:error="error"
|
|
288
|
+
hide-bottom-space
|
|
289
|
+
id="input"
|
|
290
|
+
name="input"
|
|
291
|
+
:outlined="outlined"
|
|
292
|
+
:placeholder="placeholder"
|
|
293
|
+
:readonly="readonly"
|
|
294
|
+
ref="inputRef"
|
|
295
|
+
:rules="validationRules"
|
|
296
|
+
:standout="!outlined"
|
|
297
|
+
type="text"
|
|
298
|
+
@focus="onMenuShow"
|
|
294
299
|
>
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
<div class="q-ml-xxs text-body-xs">{{ hintText }}</div>
|
|
334
|
-
</div>
|
|
335
|
-
</template>
|
|
336
|
-
|
|
337
|
-
<template #append>
|
|
338
|
-
<slot name="append">
|
|
339
|
-
<q-icon
|
|
340
|
-
v-if="rightIcon"
|
|
341
|
-
:class="`slot-icon-size-${size} ${rightIcon}`"
|
|
342
|
-
:aria-label="
|
|
343
|
-
rightIcon && rightIconAriaLabel
|
|
344
|
-
? rightIconAriaLabel
|
|
345
|
-
: 'right input icon '
|
|
346
|
-
"
|
|
347
|
-
:tabindex="0"
|
|
348
|
-
@click="handleRightIconClick"
|
|
349
|
-
/>
|
|
350
|
-
</slot>
|
|
351
|
-
</template>
|
|
352
|
-
|
|
353
|
-
<template v-slot:error>
|
|
354
|
-
<div v-if="errorMessage" class="row items-center no-wrap">
|
|
300
|
+
<!-- The 'fit' prop is used to ensure the menu matches the anchor's width for correct positioning,
|
|
301
|
+
while the manual width styling enforces a specific width for visual consistency. -->
|
|
302
|
+
<q-menu
|
|
303
|
+
v-model="resultsMenuShowing"
|
|
304
|
+
fit
|
|
305
|
+
no-focus
|
|
306
|
+
ref="resultsMenuRef"
|
|
307
|
+
:style="{ width: menuWidth }"
|
|
308
|
+
@hide="resultsMenuShowing = false"
|
|
309
|
+
@show="onMenuShow"
|
|
310
|
+
>
|
|
311
|
+
<q-list bordered>
|
|
312
|
+
<q-item
|
|
313
|
+
v-for="(p, i) of predictions"
|
|
314
|
+
clickable
|
|
315
|
+
:key="i"
|
|
316
|
+
@click="onClick(p)"
|
|
317
|
+
>
|
|
318
|
+
<q-item-section avatar>
|
|
319
|
+
<q-icon
|
|
320
|
+
class="fa-kit-duotone fa-location-dot"
|
|
321
|
+
color="primary"
|
|
322
|
+
/>
|
|
323
|
+
</q-item-section>
|
|
324
|
+
<q-item-section>
|
|
325
|
+
<q-item-label>{{ p.displayName }}</q-item-label>
|
|
326
|
+
<q-item-label caption>
|
|
327
|
+
<span class="text-caption">
|
|
328
|
+
{{ p.formattedAddress }}
|
|
329
|
+
</span>
|
|
330
|
+
</q-item-label>
|
|
331
|
+
</q-item-section>
|
|
332
|
+
</q-item>
|
|
333
|
+
</q-list>
|
|
334
|
+
</q-menu>
|
|
335
|
+
|
|
336
|
+
<template v-if="leftIcon" #prepend>
|
|
337
|
+
<slot name="prepend"></slot>
|
|
355
338
|
<q-icon
|
|
356
|
-
|
|
357
|
-
:
|
|
358
|
-
size="1rem"
|
|
339
|
+
v-if="!$slots.prepend"
|
|
340
|
+
:class="`slot-icon-size-${size} ${leftIcon}`"
|
|
359
341
|
/>
|
|
360
|
-
|
|
361
|
-
|
|
342
|
+
</template>
|
|
343
|
+
|
|
344
|
+
<template v-if="hintText" #hint>
|
|
345
|
+
<div class="row items-center text-neutral-9 no-wrap">
|
|
346
|
+
<q-icon
|
|
347
|
+
v-if="hintIcon"
|
|
348
|
+
:class="hintIcon"
|
|
349
|
+
:aria-label="hintText"
|
|
350
|
+
size="1rem"
|
|
351
|
+
/>
|
|
352
|
+
<div class="q-ml-xxs text-body-xs">{{ hintText }}</div>
|
|
353
|
+
</div>
|
|
354
|
+
</template>
|
|
355
|
+
|
|
356
|
+
<template #append>
|
|
357
|
+
<slot name="append">
|
|
358
|
+
<q-icon
|
|
359
|
+
v-if="rightIcon"
|
|
360
|
+
:class="`slot-icon-size-${size} ${rightIcon}`"
|
|
361
|
+
:aria-label="
|
|
362
|
+
rightIcon && rightIconAriaLabel
|
|
363
|
+
? rightIconAriaLabel
|
|
364
|
+
: 'right input icon '
|
|
365
|
+
"
|
|
366
|
+
:tabindex="0"
|
|
367
|
+
@click="handleRightIconClick"
|
|
368
|
+
/>
|
|
369
|
+
</slot>
|
|
370
|
+
</template>
|
|
371
|
+
|
|
372
|
+
<template v-slot:error>
|
|
373
|
+
<div v-if="errorMessage" class="row items-center no-wrap">
|
|
374
|
+
<q-icon
|
|
375
|
+
class="fa-kit-duotone fa-warning-octagon"
|
|
376
|
+
:aria-label="errorMessage"
|
|
377
|
+
size="1rem"
|
|
378
|
+
/>
|
|
379
|
+
<div class="q-ml-xxs text-body-xs" role="validation error">
|
|
380
|
+
{{ errorMessage }}
|
|
381
|
+
</div>
|
|
362
382
|
</div>
|
|
363
|
-
</
|
|
364
|
-
</
|
|
365
|
-
|
|
383
|
+
</template>
|
|
384
|
+
</q-input>
|
|
385
|
+
<q-resize-observer @resize="onResize" />
|
|
386
|
+
</div>
|
|
366
387
|
</div>
|
|
367
388
|
|
|
368
389
|
<UInputTextStd
|