@bagelink/vue 1.4.97 → 1.4.101

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.
@@ -0,0 +1,2 @@
1
+ export declare function ipapi(): Promise<any>;
2
+ //# sourceMappingURL=ipapi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ipapi.d.ts","sourceRoot":"","sources":["../../src/utils/ipapi.ts"],"names":[],"mappings":"AAEA,wBAAsB,KAAK,iBAQ1B"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "1.4.97",
4
+ "version": "1.4.101",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Neveh Allon",
@@ -29,6 +29,7 @@ const {
29
29
  popperTriggers = [],
30
30
  popperShowTriggers = [],
31
31
  popperHideTriggers = [],
32
+ showGroup,
32
33
  delay,
33
34
 
34
35
  } = defineProps<{
@@ -53,6 +54,7 @@ const {
53
54
  popperTriggers?: TriggerEvent[]
54
55
  popperShowTriggers?: TriggerEvent[]
55
56
  popperHideTriggers?: TriggerEvent[]
57
+ showGroup?: string
56
58
  delay?: number | { show: number, hide: number }
57
59
  // theme
58
60
  // referenceNode
@@ -159,7 +161,7 @@ const computedDelay = $computed((): number | { show: number, hide: number } | un
159
161
  if (delay !== undefined) return delay
160
162
  // For hover dropdowns, add a hide delay
161
163
  if (triggers.includes('hover')) {
162
- return { show: 0, hide: 50 } // 50ms delay before hiding
164
+ return { show: 0, hide: 10 } // 50ms delay before hiding
163
165
  }
164
166
  // For click dropdowns, no delay
165
167
  return 0
@@ -174,7 +176,7 @@ defineExpose({ show, hide, shown })
174
176
  :placement :autoHide="computedAutoHide" :delay="computedDelay" :triggers :showTriggers="computedShowTriggers"
175
177
  :hideTriggers="computedHideTriggers" :popperTriggers="computedPopperTriggers"
176
178
  :popperShowTriggers="computedPopperShowTriggers" :popperHideTriggers="computedPopperHideTriggers"
177
- @hide="emit('hide')" @show="emit('show')"
179
+ :showGroup="showGroup" @hide="emit('hide')" @show="emit('show')"
178
180
  >
179
181
  <div ref="triggerRef" />
180
182
  <slot name="trigger" :show :hide :shown>
@@ -1,8 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import type { Country } from '@bagelink/vue'
3
3
  import type { CountryCode } from 'libphonenumber-js'
4
- import { Dropdown, Flag, Icon, TextInput, allCountries } from '@bagelink/vue'
5
- import axios from 'axios'
4
+ import { Dropdown, Flag, Icon, TextInput, allCountries, ipapi } from '@bagelink/vue'
6
5
  import { parsePhoneNumberFromString } from 'libphonenumber-js'
7
6
  import { onMounted, watch, ref } from 'vue'
8
7
 
@@ -83,13 +82,7 @@ function selectCountry(country: Country) {
83
82
  }
84
83
 
85
84
  async function getIp() {
86
- let apiData = sessionStorage.getItem('ipapi')
87
- if (!apiData) {
88
- apiData = (await axios.get('https://ipapi.co/json/')).data
89
- apiData = JSON.stringify(apiData)
90
- sessionStorage.setItem('ipapi', apiData)
91
- }
92
- const { country_code } = JSON.parse(apiData)
85
+ const { country_code } = await ipapi()
93
86
  selectCountry(countries.find(c => c.iso2 === country_code) ?? countries[0])
94
87
  }
95
88
 
@@ -209,47 +202,30 @@ onMounted(initializeCountry)
209
202
  <label>
210
203
  {{ label }} <span v-if="required && label">*</span>
211
204
  <div
212
- dir="ltr"
213
- class="flex gap-05 tel-input"
214
- tabindex="-1"
215
- aria-label="Country Code Selector"
216
- aria-haspopup="listbox"
217
- :aria-expanded="open"
205
+ dir="ltr" class="flex gap-05 tel-input" tabindex="-1" aria-label="Country Code Selector"
206
+ aria-haspopup="listbox" :aria-expanded="open"
218
207
  >
219
208
  <Dropdown
220
- v-model:shown="open"
221
- placement="bottom-start"
222
- :disabled="disableDropdown"
209
+ v-model:shown="open" placement="bottom-start" :disabled="disableDropdown"
223
210
  @show="focusSearchInput"
224
211
  >
225
212
  <template #trigger>
226
213
  <span class="flex gap-05 country-code-display">
227
214
  <Icon v-if="!disableDropdown" :icon="open ? 'collapse_all' : 'expand_all'" />
228
- <Flag v-if="activeCountryCode" :country="activeCountryCode" />
215
+ <Flag v-if="activeCountryCode" :country="activeCountryCode" />
229
216
  </span>
230
217
  </template>
231
218
  <div class="p-075 tel-countryp-dropdown">
232
219
  <TextInput
233
- v-if="searchable"
234
- ref="searchInput"
235
- v-model="search"
236
- aria-label="Search by country name or country code"
237
- placeholder="Search"
238
- icon="search"
220
+ v-if="searchable" ref="searchInput" v-model="search"
221
+ aria-label="Search by country name or country code" placeholder="Search" icon="search"
239
222
  />
240
223
 
241
- <ul
242
- class="overflow-y p-0 max-h-300px"
243
- role="listbox"
244
- >
224
+ <ul class="overflow-y p-0 max-h-300px" role="listbox">
245
225
  <li
246
- v-for="(pb) in countries"
247
- :key="pb.iso2"
248
- role="option"
249
- class="flex gap-075 pointer hover"
250
- tabindex="-1"
251
- :aria-selected="activeCountryCode === pb.iso2"
252
- @click="selectCountry(pb)"
226
+ v-for="(pb) in countries" :key="pb.iso2" role="option"
227
+ class="flex gap-075 pointer hover" tabindex="-1"
228
+ :aria-selected="activeCountryCode === pb.iso2" @click="selectCountry(pb)"
253
229
  >
254
230
  <Flag :country="pb.iso2" />
255
231
  <p class="tel-country">{{ pb.name }}</p>
@@ -261,22 +237,10 @@ onMounted(initializeCountry)
261
237
  </div>
262
238
  </Dropdown>
263
239
  <input
264
- :id="id"
265
- ref="inputRef"
266
- v-model="phoneNumber"
267
- v-pattern.tel
268
- :required="required"
269
- :placeholder="placeholder || label || 'Phone Number'"
270
- :disabled="disabled"
271
- type="tel"
272
- autocomplete="tel"
273
- :name="id"
274
- tabindex="0"
275
- class="national-number-input"
276
- @blur="handleBlur($event)"
277
- @focus="emit('focus', $event)"
278
- @keydown="emit('keydown', $event)"
279
- @input="handlePhoneInput($event)"
240
+ :id="id" ref="inputRef" v-model="phoneNumber" v-pattern.tel :required="required"
241
+ :placeholder="placeholder || label || 'Phone Number'" :disabled="disabled" type="tel"
242
+ autocomplete="tel" :name="id" tabindex="0" class="national-number-input" @blur="handleBlur($event)"
243
+ @focus="emit('focus', $event)" @keydown="emit('keydown', $event)" @input="handlePhoneInput($event)"
280
244
  @paste="emit('paste', $event)"
281
245
  >
282
246
  </div>
@@ -353,12 +317,16 @@ onMounted(initializeCountry)
353
317
  }
354
318
 
355
319
  @keyframes highlight-country {
356
- 0%, 100% {
320
+
321
+ 0%,
322
+ 100% {
357
323
  background-color: transparent;
358
324
  }
325
+
359
326
  30% {
360
327
  background-color: var(--primary-color-light, rgba(0, 123, 255, 0.2));
361
328
  }
329
+
362
330
  70% {
363
331
  background-color: var(--primary-color-light, rgba(0, 123, 255, 0.2));
364
332
  }
package/src/index.ts CHANGED
@@ -19,4 +19,5 @@ import './styles/bagel.css'
19
19
  export * from './utils/calendar/dateUtils'
20
20
  export * from './utils/constants'
21
21
  export * from './utils/elementUtils'
22
+ export * from './utils/ipapi'
22
23
  export * from './utils/useSearch'
@@ -0,0 +1,11 @@
1
+ import axios from 'axios'
2
+
3
+ export async function ipapi() {
4
+ let apiData = sessionStorage.getItem('ipapi')
5
+ if (!apiData) {
6
+ apiData = (await axios.get('https://ipapi.co/json/')).data
7
+ apiData = JSON.stringify(apiData)
8
+ sessionStorage.setItem('ipapi', apiData)
9
+ }
10
+ return JSON.parse(apiData)
11
+ }