@usssa/component-library 1.0.0-alpha.249 → 1.0.0-alpha.250

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 CHANGED
@@ -1,4 +1,4 @@
1
- # Component Library v1.0.0-alpha.248
1
+ # Component Library v1.0.0-alpha.250
2
2
 
3
3
  **This library provides custom UI components for USSSA applications**
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usssa/component-library",
3
- "version": "1.0.0-alpha.249",
3
+ "version": "1.0.0-alpha.250",
4
4
  "description": "A Quasar component library project",
5
5
  "productName": "Quasar component library App",
6
6
  "author": "Engineering Team <engineering@usssa.com>",
@@ -1,9 +1,9 @@
1
1
  <script setup>
2
- import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
2
+ import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
3
3
  import UInputTextStd from './UInputTextStd.vue'
4
4
  import UTooltip from './UTooltip.vue'
5
5
 
6
- const emit = defineEmits(['onRightIconClick', 'onUpdate'])
6
+ const emit = defineEmits(['onRightIconClick', 'onUpdate', 'updateInputVal'])
7
7
  const modelValue = defineModel()
8
8
  defineOptions({
9
9
  inheritAttrs: false,
@@ -67,6 +67,10 @@ const props = defineProps({
67
67
  rightIconAriaLabel: {
68
68
  type: String,
69
69
  },
70
+ selectedAddress: {
71
+ type: String,
72
+ default: '',
73
+ },
70
74
  size: {
71
75
  type: String,
72
76
  default: 'md',
@@ -85,7 +89,13 @@ let sessionToken, autocompleteSuggestion
85
89
  const inputRef = ref(null)
86
90
  const menuWidth = ref(0)
87
91
  const predictions = ref([])
88
- const resultItem = ref({})
92
+ const resultItem = ref(
93
+ props.selectedAddress?.length
94
+ ? { formattedAddress: props.selectedAddress }
95
+ : modelValue.value?.length
96
+ ? { formattedAddress: modelValue.value }
97
+ : {}
98
+ )
89
99
  const resultsMenuRef = ref(null)
90
100
  const resultsMenuShowing = ref(false)
91
101
 
@@ -96,10 +106,6 @@ const leftBorderRadius = computed(() => {
96
106
  return ''
97
107
  })
98
108
 
99
- const handleClear = () => {
100
- modelValue.value = ''
101
- }
102
-
103
109
  const handleUpdate = async (input) => {
104
110
  // fetchAutocompleteSuggestions reference
105
111
  // https://developers.google.com/maps/documentation/javascript/reference/autocomplete-data#AutocompleteRequest
@@ -220,6 +226,21 @@ const parseAddressComponents = (addressComponents) => {
220
226
  return address
221
227
  }
222
228
 
229
+ const updateInputVal = (val) => {
230
+ if (!val?.length) {
231
+ modelValue.value = ''
232
+ resultItem.value = {}
233
+ }
234
+ if (val?.length === 1) {
235
+ resultItem.value = {}
236
+ modelValue.value = val
237
+ nextTick(() => {
238
+ inputRef.value?.focus()
239
+ })
240
+ }
241
+ emit('updateInputVal', val)
242
+ }
243
+
223
244
  const updateMenuWidth = () => {
224
245
  const el =
225
246
  inputRef.value?.$el.querySelector('.q-field__control') ||
@@ -240,6 +261,16 @@ watch(modelValue, async (value) => {
240
261
  emit('onUpdate', {})
241
262
  }
242
263
  })
264
+
265
+ watch(
266
+ () => resultItem.value?.formattedAddress,
267
+ (value) => {
268
+ if (!value)
269
+ nextTick(() => {
270
+ inputRef.value?.focus()
271
+ })
272
+ }
273
+ )
243
274
  </script>
244
275
 
245
276
  <template>
@@ -296,6 +327,7 @@ watch(modelValue, async (value) => {
296
327
  :standout="!outlined"
297
328
  type="text"
298
329
  @focus="onMenuShow"
330
+ @update:modelValue="updateInputVal($event)"
299
331
  >
300
332
  <!-- The 'fit' prop is used to ensure the menu matches the anchor's width for correct positioning,
301
333
  while the manual width styling enforces a specific width for visual consistency. -->
@@ -391,10 +423,8 @@ watch(modelValue, async (value) => {
391
423
  v-model="resultItem.formattedAddress"
392
424
  :dataTestId="dataTestId"
393
425
  :label="label"
394
- readonly
395
- rightIcon="fa-kit-duotone fa-circle-xmark"
396
426
  :size="size"
397
- @onRightIconClick="handleClear"
427
+ @update:modelValue="updateInputVal($event)"
398
428
  />
399
429
  </template>
400
430
 
@@ -68,6 +68,7 @@ const getTooltipText = computed(() => {
68
68
  border-radius: $xs
69
69
  padding: $xs $sm
70
70
  max-width: 22.5rem !important
71
+ word-break: break-word
71
72
 
72
73
  .tooltip-text
73
74
  color: $neutral-1