@bagelink/vue 0.0.687 → 0.0.689

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.
@@ -66,18 +66,18 @@ const defaultDropdownOptions = {
66
66
  }
67
67
 
68
68
  const defaultInputOptions = {
69
- showDialCode: true,
70
- autofocus: false,
69
+ 'showDialCode': true,
70
+ 'autofocus': false,
71
71
  'aria-describedby': '',
72
- id: '',
73
- maxlength: 25,
74
- minlength: 9,
75
- pattern: undefined as string | undefined,
76
- name: '',
77
- readonly: false,
78
- tabindex: 0,
79
- style: '' as Raw<StyleValue>,
80
- placeholder: 'Enter a phone number',
72
+ 'id': '',
73
+ 'maxlength': 25,
74
+ 'minlength': 9,
75
+ 'pattern': undefined as string | undefined,
76
+ 'name': '',
77
+ 'readonly': false,
78
+ 'tabindex': 0,
79
+ 'style': '' as Raw<StyleValue>,
80
+ 'placeholder': 'Enter a phone number',
81
81
  }
82
82
 
83
83
  interface Props {
@@ -123,26 +123,22 @@ const searchQuery = $ref('')
123
123
  // const refInput = $ref<HTMLInputElement | null>(null)
124
124
 
125
125
  // Computed: activeCountry
126
- const activeCountry = $computed(() =>
127
- props.allCountries.find(
128
- country => country.iso2 === activeCountryCode?.toUpperCase()
129
- )
126
+ const activeCountry = $computed(() => props.allCountries.find(
127
+ country => country.iso2 === activeCountryCode?.toUpperCase(),
128
+ ),
130
129
  )
131
130
 
132
- const isPreferred = (country?: Country) =>
133
- props.preferredCountries.includes(country?.iso2 as CountryCode)
131
+ const isPreferred = (country?: Country) => props.preferredCountries.includes(country?.iso2 as CountryCode)
134
132
 
135
133
  const filteredCountries = $computed(() => {
136
134
  if (props.onlyCountries.length) {
137
- return props.allCountries.filter(({ iso2 }) =>
138
- props.onlyCountries.some(c => c.toUpperCase() === iso2)
135
+ return props.allCountries.filter(({ iso2 }) => props.onlyCountries.some(c => c.toUpperCase() === iso2),
139
136
  )
140
137
  }
141
138
  if (props.excludeCountries.length) {
142
139
  return props.allCountries.filter(
143
- ({ iso2 }) =>
144
- !props.excludeCountries.includes(iso2.toUpperCase()) &&
145
- !props.excludeCountries.includes(iso2.toLowerCase())
140
+ ({ iso2 }) => !props.excludeCountries.includes(iso2.toUpperCase())
141
+ && !props.excludeCountries.includes(iso2.toLowerCase()),
146
142
  )
147
143
  }
148
144
  return props.allCountries
@@ -155,14 +151,13 @@ const sortedCountries = $computed(() => {
155
151
  const cleanInput = searchQuery.replace(
156
152
  // eslint-disable-next-line regexp/no-obscure-range
157
153
  /[~`!#$%&*()+={};:'"<>.,/?-_]/g,
158
- ''
154
+ '',
159
155
  )
160
156
  return countriesList
161
157
  .filter(
162
- c =>
163
- new RegExp(cleanInput, 'i').test(c.name || '') ||
164
- new RegExp(cleanInput, 'i').test(c.iso2 || '') ||
165
- new RegExp(cleanInput, 'i').test(c.dialCode || '')
158
+ c => new RegExp(cleanInput, 'i').test(c.name || '')
159
+ || new RegExp(cleanInput, 'i').test(c.iso2 || '')
160
+ || new RegExp(cleanInput, 'i').test(c.dialCode || ''),
166
161
  )
167
162
  .filter(Boolean)
168
163
  })
@@ -174,21 +169,16 @@ const parseArgs = $computed(() => ({
174
169
 
175
170
  const phone = defineModel<string>('modelValue', {
176
171
  default: '',
177
- set: value => {
172
+ set: (value) => {
178
173
  let maybeFormatted = value
179
174
  if (value.length > 5) {
180
175
  maybeFormatted = formatPhone(`${value}`)
181
176
 
182
- if (!maybeFormatted) {
183
- emit('update:modelValue', '')
184
- return ''
185
- }
177
+ if (!maybeFormatted) { emit('update:modelValue', ''); return '' }
186
178
  }
187
179
 
188
180
  emit('update:modelValue', maybeFormatted)
189
- debounce(() => {
190
- emit('debounce', maybeFormatted)
191
- }, props.debounceDelay)
181
+ debounce(() => { emit('debounce', maybeFormatted) }, props.debounceDelay)
192
182
  return maybeFormatted
193
183
  },
194
184
  get: value => value,
@@ -199,8 +189,8 @@ function formatPhone(val: string): string {
199
189
  console.log('Phone Number:', phoneNumber)
200
190
 
201
191
  if (!phoneNumber) {
202
- const dialCode =
203
- sortedCountries.find(c => c.iso2 === activeCountryCode)?.dialCode || ''
192
+ const dialCode
193
+ = sortedCountries.find(c => c.iso2 === activeCountryCode)?.dialCode || ''
204
194
  if (props.mode === 'INTERNATIONAL') return `+${dialCode}`
205
195
  return dialCode
206
196
  }
@@ -217,21 +207,11 @@ watch(
217
207
  }
218
208
  // eslint-disable-next-line vue/custom-event-name-casing
219
209
  if (value?.iso2) emit('country-changed', value)
220
- }
210
+ },
221
211
  )
222
212
 
223
213
  async function initializeCountry() {
224
- if (props.modelValue.includes('+')) {
225
- const sanitized = `${props.modelValue}`.replace(/[\+\-\s]/gi, '')
226
- const twoDigits = sanitized.slice(0, 2)
227
- const threeDigits = sanitized.slice(0, 3)
228
- const country =
229
- findCountryByDialCode(+threeDigits) || findCountryByDialCode(+twoDigits)
230
- if (country) {
231
- chooseCountry(country.iso2)
232
- return
233
- }
234
- }
214
+ // if (phone?.[0] === '+') return;
235
215
  // 2. Use default country if passed from parent
236
216
  if (props.defaultCountry) {
237
217
  if (typeof props.defaultCountry === 'string') {
@@ -265,12 +245,11 @@ async function initializeCountry() {
265
245
 
266
246
  onMounted(initializeCountry)
267
247
 
268
- const findCountry = (iso: string) =>
269
- filteredCountries.find(country => country.iso2 === iso.toUpperCase())
248
+ const findCountry = (iso: string) => filteredCountries.find(country => country.iso2 === iso.toUpperCase())
270
249
 
271
250
  function getCountries(list: string[]): Country[] {
272
251
  const countryList: Country[] = []
273
- list.forEach(countryCode => {
252
+ list.forEach((countryCode) => {
274
253
  const country = findCountry(countryCode)
275
254
  if (country) countryList.push(country)
276
255
  })
@@ -278,9 +257,7 @@ function getCountries(list: string[]): Country[] {
278
257
  }
279
258
 
280
259
  function findCountryByDialCode(dialCode: number) {
281
- return filteredCountries.find(
282
- country => Number(country.dialCode) === dialCode
283
- )
260
+ return filteredCountries.find(country => Number(country.dialCode) === dialCode)
284
261
  }
285
262
 
286
263
  function chooseCountry(country?: string) {
@@ -299,27 +276,21 @@ function chooseCountry(country?: string) {
299
276
  // emitInput(phone);
300
277
  }
301
278
 
302
- function onBlur() {
303
- emit('blur')
304
- }
279
+ function onBlur() { emit('blur') }
305
280
 
306
- function onFocus() {
307
- emit('focus')
308
- }
281
+ function onFocus() { emit('focus') }
309
282
 
310
- function onEnter(e: KeyboardEvent) {
311
- emit('enter')
312
- }
283
+ function onEnter(e: KeyboardEvent) { emit('enter') }
313
284
 
314
- function onSpace() {
315
- emit('space')
316
- }
285
+ function onSpace() { emit('space') }
317
286
 
318
287
  // const focus = () => refInput?.focus();
319
288
 
320
289
  // Method: reset
321
290
  function reset() {
322
- selectedIndex = sortedCountries.findIndex(c => c.iso2 === activeCountryCode)
291
+ selectedIndex = sortedCountries.findIndex(
292
+ c => c.iso2 === activeCountryCode,
293
+ )
323
294
  open = false
324
295
  }
325
296
 
@@ -336,7 +307,10 @@ function handleInput(e: KeyboardEvent) {
336
307
  </script>
337
308
 
338
309
  <template>
339
- <div class="bagel-input" :class="{ disabled }">
310
+ <div
311
+ class="bagel-input"
312
+ :class="{ disabled }"
313
+ >
340
314
  <label>
341
315
  {{ label }}
342
316
  <div
@@ -355,7 +329,10 @@ function handleInput(e: KeyboardEvent) {
355
329
  :disabled="computedDropDownOptions.disabled"
356
330
  @hide="open = false"
357
331
  >
358
- <span class="flex gap-05" @click="open = true">
332
+ <span
333
+ class="flex gap-05"
334
+ @click="open = true"
335
+ >
359
336
  <Icon :icon="open ? 'collapse_all' : 'expand_all'" />
360
337
  <Flag
361
338
  v-if="computedDropDownOptions.showFlags && activeCountryCode"
@@ -384,10 +361,12 @@ function handleInput(e: KeyboardEvent) {
384
361
  role="option"
385
362
  class="flex gap-075"
386
363
  tabindex="-1"
387
- :aria-selected="
388
- activeCountryCode === pb.iso2 && !isPreferred(pb)
364
+ :aria-selected="activeCountryCode === pb.iso2 && !isPreferred(pb)
365
+ "
366
+ @click="
367
+ chooseCountry(pb.iso2);
368
+ hide();
389
369
  "
390
- @click="hide() && chooseCountry(pb.iso2)"
391
370
  @mousemove="selectedIndex = index"
392
371
  >
393
372
  <Flag
@@ -427,7 +406,7 @@ function handleInput(e: KeyboardEvent) {
427
406
  @keyup.enter="onEnter"
428
407
  @keyup.space="onSpace"
429
408
  @keydown="handleInput"
430
- />
409
+ >
431
410
  </div>
432
411
  </label>
433
412
  </div>
@@ -1784,7 +1784,7 @@
1784
1784
  height: 10px;
1785
1785
  }
1786
1786
 
1787
- .hm-10px, .max-h-10px {
1787
+ .hm-10px {
1788
1788
  max-height: 10px;
1789
1789
  }
1790
1790
 
@@ -1801,7 +1801,7 @@
1801
1801
  height: 20px;
1802
1802
  }
1803
1803
 
1804
- .hm-20px, .max-h-20px {
1804
+ .hm-20px {
1805
1805
  max-height: 20px;
1806
1806
  }
1807
1807
 
@@ -1817,7 +1817,7 @@
1817
1817
  height: 30px;
1818
1818
  }
1819
1819
 
1820
- .hm-30px, .max-h-30px {
1820
+ .hm-30px {
1821
1821
  max-height: 30px;
1822
1822
  }
1823
1823
 
@@ -1833,7 +1833,7 @@
1833
1833
  height: 40px;
1834
1834
  }
1835
1835
 
1836
- .hm-40px, .max-h-40px {
1836
+ .hm-40px {
1837
1837
  max-height: 40px;
1838
1838
  }
1839
1839
 
@@ -1849,7 +1849,7 @@
1849
1849
  height: 50px;
1850
1850
  }
1851
1851
 
1852
- .hm-50px, .max-h-50px {
1852
+ .hm-50px {
1853
1853
  max-height: 50px;
1854
1854
  }
1855
1855
 
@@ -1865,7 +1865,7 @@
1865
1865
  height: 60px;
1866
1866
  }
1867
1867
 
1868
- .hm-60px, .max-h-60px {
1868
+ .hm-60px {
1869
1869
  max-height: 60px;
1870
1870
  }
1871
1871
 
@@ -1881,7 +1881,7 @@
1881
1881
  height: 70px;
1882
1882
  }
1883
1883
 
1884
- .hm-70px, .max-h-70px {
1884
+ .hm-70px {
1885
1885
  max-height: 70px;
1886
1886
  }
1887
1887
 
@@ -1897,7 +1897,7 @@
1897
1897
  height: 80px;
1898
1898
  }
1899
1899
 
1900
- .hm-80px, .max-h-80px {
1900
+ .hm-80px {
1901
1901
  max-height: 80px;
1902
1902
  }
1903
1903
 
@@ -1913,10 +1913,11 @@
1913
1913
  height: 90px;
1914
1914
  }
1915
1915
 
1916
- .hm-90px, .max-h-90px {
1916
+ .hm-90px {
1917
1917
  max-height: 90px;
1918
1918
  }
1919
1919
 
1920
+
1920
1921
  .h-100 {
1921
1922
  height: 100%;
1922
1923
  }
@@ -1929,7 +1930,7 @@
1929
1930
  height: 100px !important;
1930
1931
  }
1931
1932
 
1932
- .hm-100px, .max-h-100px {
1933
+ .hm-100px {
1933
1934
  max-height: 100px;
1934
1935
  }
1935
1936
 
@@ -1945,7 +1946,7 @@
1945
1946
  height: 150px;
1946
1947
  }
1947
1948
 
1948
- .hm-150px, .max-h-150px {
1949
+ .hm-150px {
1949
1950
  max-height: 150px;
1950
1951
  }
1951
1952
 
@@ -1961,7 +1962,7 @@
1961
1962
  height: 200px;
1962
1963
  }
1963
1964
 
1964
- .hm-200px, .max-h-200px {
1965
+ .hm-200px {
1965
1966
  max-height: 200px;
1966
1967
  }
1967
1968
 
@@ -1977,7 +1978,7 @@
1977
1978
  height: 300px;
1978
1979
  }
1979
1980
 
1980
- .hm-300px, .max-h-300px {
1981
+ .hm-300px {
1981
1982
  max-height: 300px;
1982
1983
  }
1983
1984
 
@@ -1993,7 +1994,7 @@
1993
1994
  height: 400px;
1994
1995
  }
1995
1996
 
1996
- .hm-400px, .max-h-400px {
1997
+ .hm-400px {
1997
1998
  max-height: 400px;
1998
1999
  }
1999
2000
 
@@ -2009,7 +2010,7 @@
2009
2010
  height: 500px;
2010
2011
  }
2011
2012
 
2012
- .hm-500px, .max-h-500px {
2013
+ .hm-500px {
2013
2014
  max-height: 500px;
2014
2015
  }
2015
2016
 
@@ -2025,44 +2026,10 @@
2025
2026
  height: 600px;
2026
2027
  }
2027
2028
 
2028
- .hm-600px, .max-h-600px {
2029
+ .hm-600px {
2029
2030
  max-height: 600px;
2030
2031
  }
2031
2032
 
2032
- .hm-10vh, .max-h-10vh {
2033
- max-height: 10vh;
2034
- }
2035
- .hm-20vh, .max-h-20vh {
2036
- max-height: 20vh;
2037
- }
2038
- .hm-30vh, .max-h-30vh {
2039
- max-height: 30vh;
2040
- }
2041
- .hm-40vh, .max-h-40vh {
2042
- max-height: 40vh;
2043
- }
2044
- .hm-50vh, .max-h-50vh {
2045
- max-height: 50vh;
2046
- }
2047
- .hm-60vh, .max-h-60vh {
2048
- max-height: 60vh;
2049
- }
2050
- .hm-70vh, .max-h-70vh {
2051
- max-height: 70vh;
2052
- }
2053
- .hm-80vh, .max-h-80vh {
2054
- max-height: 80vh;
2055
- }
2056
- .hm-90vh, .max-h-90vh {
2057
- max-height: 90vh;
2058
- }
2059
- .hm-100vh, .max-h-100vh {
2060
- max-height: 100vh;
2061
- }
2062
-
2063
-
2064
-
2065
-
2066
2033
 
2067
2034
  .layout-h-100 {
2068
2035
  height: 100vh;
@@ -1417,7 +1417,7 @@
1417
1417
  height: 10px;
1418
1418
  }
1419
1419
 
1420
- .m_hm-10px, .max-h-10px {
1420
+ .m_hm-10px {
1421
1421
  max-height: 10px;
1422
1422
  }
1423
1423
 
@@ -1434,7 +1434,7 @@
1434
1434
  height: 20px;
1435
1435
  }
1436
1436
 
1437
- .m_hm-20px, .max-h-20px {
1437
+ .m_hm-20px {
1438
1438
  max-height: 20px;
1439
1439
  }
1440
1440
 
@@ -1450,7 +1450,7 @@
1450
1450
  height: 30px;
1451
1451
  }
1452
1452
 
1453
- .m_hm-30px, .max-h-30px {
1453
+ .m_hm-30px {
1454
1454
  max-height: 30px;
1455
1455
  }
1456
1456
 
@@ -1466,7 +1466,7 @@
1466
1466
  height: 40px;
1467
1467
  }
1468
1468
 
1469
- .m_hm-40px, .max-h-40px {
1469
+ .m_hm-40px {
1470
1470
  max-height: 40px;
1471
1471
  }
1472
1472
 
@@ -1482,7 +1482,7 @@
1482
1482
  height: 50px;
1483
1483
  }
1484
1484
 
1485
- .m_hm-50px, .max-h-50px {
1485
+ .m_hm-50px {
1486
1486
  max-height: 50px;
1487
1487
  }
1488
1488
 
@@ -1498,7 +1498,7 @@
1498
1498
  height: 60px;
1499
1499
  }
1500
1500
 
1501
- .m_hm-60px, .max-h-60px {
1501
+ .m_hm-60px {
1502
1502
  max-height: 60px;
1503
1503
  }
1504
1504
 
@@ -1514,7 +1514,7 @@
1514
1514
  height: 70px;
1515
1515
  }
1516
1516
 
1517
- .m_hm-70px, .max-h-70px {
1517
+ .m_hm-70px {
1518
1518
  max-height: 70px;
1519
1519
  }
1520
1520
 
@@ -1530,7 +1530,7 @@
1530
1530
  height: 80px;
1531
1531
  }
1532
1532
 
1533
- .m_hm-80px, .max-h-80px {
1533
+ .m_hm-80px {
1534
1534
  max-height: 80px;
1535
1535
  }
1536
1536
 
@@ -1546,7 +1546,7 @@
1546
1546
  height: 90px;
1547
1547
  }
1548
1548
 
1549
- .m_hm-90px, .max-h-90px {
1549
+ .m_hm-90px {
1550
1550
  max-height: 90px;
1551
1551
  }
1552
1552
 
@@ -1563,7 +1563,7 @@
1563
1563
  height: 100px;
1564
1564
  }
1565
1565
 
1566
- .m_hm-100px, .max-h-100px {
1566
+ .m_hm-100px {
1567
1567
  max-height: 100px;
1568
1568
  }
1569
1569
 
@@ -1579,7 +1579,7 @@
1579
1579
  height: 150px;
1580
1580
  }
1581
1581
 
1582
- .m_hm-150px, .max-h-150px {
1582
+ .m_hm-150px {
1583
1583
  max-height: 150px;
1584
1584
  }
1585
1585
 
@@ -1595,7 +1595,7 @@
1595
1595
  height: 200px;
1596
1596
  }
1597
1597
 
1598
- .m_hm-200px, .max-h-200px {
1598
+ .m_hm-200px {
1599
1599
  max-height: 200px;
1600
1600
  }
1601
1601
 
@@ -1611,7 +1611,7 @@
1611
1611
  height: 300px;
1612
1612
  }
1613
1613
 
1614
- .m_hm-300px, .max-h-300px {
1614
+ .m_hm-300px {
1615
1615
  max-height: 300px;
1616
1616
  }
1617
1617
 
@@ -1627,7 +1627,7 @@
1627
1627
  height: 400px;
1628
1628
  }
1629
1629
 
1630
- .m_hm-400px, .max-h-400px {
1630
+ .m_hm-400px {
1631
1631
  max-height: 400px;
1632
1632
  }
1633
1633
 
@@ -1643,7 +1643,7 @@
1643
1643
  height: 500px;
1644
1644
  }
1645
1645
 
1646
- .m_hm-500px, .max-h-500px {
1646
+ .m_hm-500px {
1647
1647
  max-height: 500px;
1648
1648
  }
1649
1649
 
@@ -1659,41 +1659,10 @@
1659
1659
  height: 600px;
1660
1660
  }
1661
1661
 
1662
- .m_hm-600px, .m_max-h-600px {
1662
+ .m_hm-600px {
1663
1663
  max-height: 600px;
1664
1664
  }
1665
1665
 
1666
- .m_hm-10vh, .m_max-h-10vh {
1667
- max-height: 10vh;
1668
- }
1669
- .m_hm-20vh, .m_max-h-20vh {
1670
- max-height: 20vh;
1671
- }
1672
- .m_hm-30vh, .m_max-h-30vh {
1673
- max-height: 30vh;
1674
- }
1675
- .m_hm-40vh, .m_max-h-40vh {
1676
- max-height: 40vh;
1677
- }
1678
- .m_hm-50vh, .m_max-h-50vh {
1679
- max-height: 50vh;
1680
- }
1681
- .m_hm-60vh, .m_max-h-60vh {
1682
- max-height: 60vh;
1683
- }
1684
- .m_hm-70vh, .m_max-h-70vh {
1685
- max-height: 70vh;
1686
- }
1687
- .m_hm-80vh, .m_max-h-80vh {
1688
- max-height: 80vh;
1689
- }
1690
- .m_hm-90vh, .m_max-h-90vh {
1691
- max-height: 90vh;
1692
- }
1693
- .m_hm-100vh, .m_max-h-100vh {
1694
- max-height: 100vh;
1695
- }
1696
-
1697
1666
 
1698
1667
  .m_layout-h-100 {
1699
1668
  height: 100vh;
@@ -341,10 +341,6 @@
341
341
  font-family: "Material Symbols Outlined", serif !important;
342
342
  }
343
343
 
344
- .user-select-none{
345
- user-select: none;
346
- }
347
-
348
344
  .nowrap {
349
345
  white-space: nowrap;
350
346
  }
@@ -711,10 +707,6 @@
711
707
  white-space: nowrap;
712
708
  }
713
709
 
714
- .m_user-select-none{
715
- user-select: none;
716
- }
717
-
718
710
  .m_balance {
719
711
  text-wrap: balance;
720
712
  }
@@ -33,7 +33,6 @@ export type ThemeType = |
33
33
  | 'primary'
34
34
  | 'blue' // ! blue does nothing
35
35
 
36
- // | boolean TODO: add to option type
37
36
  export type Option =
38
37
  | string
39
38
  | number
package/src/utils/lang.ts CHANGED
@@ -12,21 +12,14 @@ const state: State = reactive({
12
12
  lang: 'en',
13
13
  })
14
14
 
15
- function $tdb<T extends Record<string, any>>(langEl?: T): string {
16
- if (!langEl) {
17
- console.warn('No language element provided for $tdb function')
18
- return ''
19
- }
20
-
21
- return langEl[state.lang] || langEl[state.defaultLang] || ''
22
- }
23
-
24
15
  export function useLang() {
25
16
  const lang = computed({
26
17
  get: () => state.lang,
27
18
  set: val => (state.lang = val),
28
19
  })
29
20
 
21
+ const $tdb = (langEl: Record<string, any>) => langEl[state.lang] || langEl[state.defaultLang] || ''
22
+
30
23
  const availableLangs = computed({
31
24
  get: () => state.availableLangs,
32
25
  set: val => (state.availableLangs = val),