@salla.sa/ui-address-autocomplete-widget 1.0.6 → 1.1.0
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/index.js +82 -25
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const U = globalThis,
|
|
1
|
+
const U = globalThis, B = U.ShadowRoot && (U.ShadyCSS === void 0 || U.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, H = /* @__PURE__ */ Symbol(), Z = /* @__PURE__ */ new WeakMap();
|
|
2
2
|
let le = class {
|
|
3
3
|
constructor(e, t, s) {
|
|
4
4
|
if (this._$cssResult$ = !0, s !== H) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
|
|
@@ -7,7 +7,7 @@ let le = class {
|
|
|
7
7
|
get styleSheet() {
|
|
8
8
|
let e = this.o;
|
|
9
9
|
const t = this.t;
|
|
10
|
-
if (
|
|
10
|
+
if (B && e === void 0) {
|
|
11
11
|
const s = t !== void 0 && t.length === 1;
|
|
12
12
|
s && (e = Z.get(t)), e === void 0 && ((this.o = e = new CSSStyleSheet()).replaceSync(this.cssText), s && Z.set(t, e));
|
|
13
13
|
}
|
|
@@ -25,12 +25,12 @@ const ue = (i) => new le(typeof i == "string" ? i : i + "", void 0, H), me = (i,
|
|
|
25
25
|
})(r) + i[o + 1], i[0]);
|
|
26
26
|
return new le(t, i, H);
|
|
27
27
|
}, fe = (i, e) => {
|
|
28
|
-
if (
|
|
28
|
+
if (B) i.adoptedStyleSheets = e.map((t) => t instanceof CSSStyleSheet ? t : t.styleSheet);
|
|
29
29
|
else for (const t of e) {
|
|
30
30
|
const s = document.createElement("style"), r = U.litNonce;
|
|
31
31
|
r !== void 0 && s.setAttribute("nonce", r), s.textContent = t.cssText, i.appendChild(s);
|
|
32
32
|
}
|
|
33
|
-
}, Y =
|
|
33
|
+
}, Y = B ? (i) => i : (i) => i instanceof CSSStyleSheet ? ((e) => {
|
|
34
34
|
let t = "";
|
|
35
35
|
for (const s of e.cssRules) t += s.cssText;
|
|
36
36
|
return ue(t);
|
|
@@ -266,13 +266,13 @@ const ke = (i, e) => {
|
|
|
266
266
|
}
|
|
267
267
|
return [pe(i, o + (i[t] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), s];
|
|
268
268
|
};
|
|
269
|
-
class
|
|
269
|
+
class N {
|
|
270
270
|
constructor({ strings: e, _$litType$: t }, s) {
|
|
271
271
|
let r;
|
|
272
272
|
this.parts = [];
|
|
273
273
|
let o = 0, a = 0;
|
|
274
274
|
const n = e.length - 1, l = this.parts, [m, c] = ke(e, t);
|
|
275
|
-
if (this.el =
|
|
275
|
+
if (this.el = N.createElement(m, s), w.currentNode = this.el.content, t === 2 || t === 3) {
|
|
276
276
|
const u = this.el.content.firstChild;
|
|
277
277
|
u.replaceWith(...u.childNodes);
|
|
278
278
|
}
|
|
@@ -326,7 +326,7 @@ class Pe {
|
|
|
326
326
|
for (; l !== void 0; ) {
|
|
327
327
|
if (a === l.index) {
|
|
328
328
|
let m;
|
|
329
|
-
l.type === 2 ? m = new
|
|
329
|
+
l.type === 2 ? m = new I(o, o.nextSibling, this, e) : l.type === 1 ? m = new l.ctor(o, l.name, l.strings, this, e) : l.type === 6 && (m = new Ne(o, this, e)), this._$AV.push(m), l = s[++n];
|
|
330
330
|
}
|
|
331
331
|
a !== l?.index && (o = w.nextNode(), a++);
|
|
332
332
|
}
|
|
@@ -337,7 +337,7 @@ class Pe {
|
|
|
337
337
|
for (const s of this._$AV) s !== void 0 && (s.strings !== void 0 ? (s._$AI(e, s, t), t += s.strings.length - 2) : s._$AI(e[t])), t++;
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
|
-
class
|
|
340
|
+
class I {
|
|
341
341
|
get _$AU() {
|
|
342
342
|
return this._$AM?._$AU ?? this._$Cv;
|
|
343
343
|
}
|
|
@@ -368,7 +368,7 @@ class N {
|
|
|
368
368
|
this._$AH !== f && R(this._$AH) ? this._$AA.nextSibling.data = e : this.T(_.createTextNode(e)), this._$AH = e;
|
|
369
369
|
}
|
|
370
370
|
$(e) {
|
|
371
|
-
const { values: t, _$litType$: s } = e, r = typeof s == "number" ? this._$AC(e) : (s.el === void 0 && (s.el =
|
|
371
|
+
const { values: t, _$litType$: s } = e, r = typeof s == "number" ? this._$AC(e) : (s.el === void 0 && (s.el = N.createElement(pe(s.h, s.h[0]), this.options)), s);
|
|
372
372
|
if (this._$AH?._$AD === r) this._$AH.p(t);
|
|
373
373
|
else {
|
|
374
374
|
const o = new Pe(r, this), a = o.u(this.options);
|
|
@@ -377,13 +377,13 @@ class N {
|
|
|
377
377
|
}
|
|
378
378
|
_$AC(e) {
|
|
379
379
|
let t = oe.get(e.strings);
|
|
380
|
-
return t === void 0 && oe.set(e.strings, t = new
|
|
380
|
+
return t === void 0 && oe.set(e.strings, t = new N(e)), t;
|
|
381
381
|
}
|
|
382
382
|
k(e) {
|
|
383
383
|
K(this._$AH) || (this._$AH = [], this._$AR());
|
|
384
384
|
const t = this._$AH;
|
|
385
385
|
let s, r = 0;
|
|
386
|
-
for (const o of e) r === t.length ? t.push(s = new
|
|
386
|
+
for (const o of e) r === t.length ? t.push(s = new I(this.O(C()), this.O(C()), this, this.options)) : s = t[r], s._$AI(o), r++;
|
|
387
387
|
r < t.length && (this._$AR(s && s._$AB.nextSibling, r), t.length = r);
|
|
388
388
|
}
|
|
389
389
|
_$AR(e = this._$AA.nextSibling, t) {
|
|
@@ -450,7 +450,7 @@ class Re extends M {
|
|
|
450
450
|
typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, e) : this._$AH.handleEvent(e);
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
|
-
class
|
|
453
|
+
class Ne {
|
|
454
454
|
constructor(e, t, s) {
|
|
455
455
|
this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = s;
|
|
456
456
|
}
|
|
@@ -461,14 +461,14 @@ class Ie {
|
|
|
461
461
|
E(this, e);
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
|
-
const
|
|
465
|
-
|
|
464
|
+
const Ie = W.litHtmlPolyfillSupport;
|
|
465
|
+
Ie?.(N, I), (W.litHtmlVersions ??= []).push("3.3.2");
|
|
466
466
|
const ze = (i, e, t) => {
|
|
467
467
|
const s = t?.renderBefore ?? e;
|
|
468
468
|
let r = s._$litPart$;
|
|
469
469
|
if (r === void 0) {
|
|
470
470
|
const o = t?.renderBefore ?? null;
|
|
471
|
-
s._$litPart$ = r = new
|
|
471
|
+
s._$litPart$ = r = new I(e.insertBefore(C(), o), o, void 0, t ?? {});
|
|
472
472
|
}
|
|
473
473
|
return r._$AI(i), r;
|
|
474
474
|
};
|
|
@@ -543,8 +543,8 @@ function Me(i, e) {
|
|
|
543
543
|
} });
|
|
544
544
|
};
|
|
545
545
|
}
|
|
546
|
-
const Le = { ATTRIBUTE: 1 },
|
|
547
|
-
class
|
|
546
|
+
const Le = { ATTRIBUTE: 1 }, qe = (i) => (...e) => ({ _$litDirective$: i, values: e });
|
|
547
|
+
class Be {
|
|
548
548
|
constructor(e) {
|
|
549
549
|
}
|
|
550
550
|
get _$AU() {
|
|
@@ -560,7 +560,7 @@ class qe {
|
|
|
560
560
|
return this.render(...t);
|
|
561
561
|
}
|
|
562
562
|
}
|
|
563
|
-
const F =
|
|
563
|
+
const F = qe(class extends Be {
|
|
564
564
|
constructor(i) {
|
|
565
565
|
if (super(i), i.type !== Le.ATTRIBUTE || i.name !== "class" || i.strings?.length > 2) throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.");
|
|
566
566
|
}
|
|
@@ -824,7 +824,7 @@ const ne = {
|
|
|
824
824
|
validationSaudiFormat: "Lütfen geçerli bir Suudi ulusal adresi girin (format: AAAA1234)"
|
|
825
825
|
}
|
|
826
826
|
};
|
|
827
|
-
function
|
|
827
|
+
function q(i = "en") {
|
|
828
828
|
return ne[i] || ne.en;
|
|
829
829
|
}
|
|
830
830
|
function Ge(i) {
|
|
@@ -965,7 +965,7 @@ let d = class extends T {
|
|
|
965
965
|
} : null;
|
|
966
966
|
} catch (e) {
|
|
967
967
|
console.error("Error fetching place details:", e);
|
|
968
|
-
const t =
|
|
968
|
+
const t = q(this.language);
|
|
969
969
|
return this.error = e instanceof Error ? e.message : t.errorFetchDetails, null;
|
|
970
970
|
} finally {
|
|
971
971
|
this.isLoading = !1;
|
|
@@ -1080,7 +1080,7 @@ let d = class extends T {
|
|
|
1080
1080
|
validate() {
|
|
1081
1081
|
if (this.mode !== "form")
|
|
1082
1082
|
return !0;
|
|
1083
|
-
const i =
|
|
1083
|
+
const i = q(this.language), e = this.inputValue || "";
|
|
1084
1084
|
return this.required && !e.trim() ? (this.validationError = i.validationRequired, this._internals.setValidity(
|
|
1085
1085
|
{ valueMissing: !0 },
|
|
1086
1086
|
this.validationError,
|
|
@@ -1095,10 +1095,67 @@ let d = class extends T {
|
|
|
1095
1095
|
this.inputElement
|
|
1096
1096
|
), !1) : (this.validationError = null, this._internals.setValidity({}), !0);
|
|
1097
1097
|
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Normalize numerals from various scripts to Arabic numerals (0-9).
|
|
1100
|
+
* Handles Arabic-Indic, Devanagari (Hindi), Persian, and Bengali numerals.
|
|
1101
|
+
* Works consistently across all browsers and operating systems.
|
|
1102
|
+
*/
|
|
1103
|
+
normalizeNumerals(i) {
|
|
1104
|
+
if (!i) return i;
|
|
1105
|
+
const e = {
|
|
1106
|
+
// Arabic-Indic numerals (used in Arab countries): ٠١٢٣٤٥٦٧٨٩
|
|
1107
|
+
"٠": "0",
|
|
1108
|
+
"١": "1",
|
|
1109
|
+
"٢": "2",
|
|
1110
|
+
"٣": "3",
|
|
1111
|
+
"٤": "4",
|
|
1112
|
+
"٥": "5",
|
|
1113
|
+
"٦": "6",
|
|
1114
|
+
"٧": "7",
|
|
1115
|
+
"٨": "8",
|
|
1116
|
+
"٩": "9",
|
|
1117
|
+
// Devanagari (Hindi) numerals (used in India, Nepal): ०१२३४५६७८९
|
|
1118
|
+
"०": "0",
|
|
1119
|
+
"१": "1",
|
|
1120
|
+
"२": "2",
|
|
1121
|
+
"३": "3",
|
|
1122
|
+
"४": "4",
|
|
1123
|
+
"५": "5",
|
|
1124
|
+
"६": "6",
|
|
1125
|
+
"७": "7",
|
|
1126
|
+
"८": "8",
|
|
1127
|
+
"९": "9",
|
|
1128
|
+
// Persian/Dari numerals (used in Iran, Afghanistan): ۰۱۲۳۴۵۶۷۸۹
|
|
1129
|
+
"۰": "0",
|
|
1130
|
+
"۱": "1",
|
|
1131
|
+
"۲": "2",
|
|
1132
|
+
"۳": "3",
|
|
1133
|
+
"۴": "4",
|
|
1134
|
+
"۵": "5",
|
|
1135
|
+
"۶": "6",
|
|
1136
|
+
"۷": "7",
|
|
1137
|
+
"۸": "8",
|
|
1138
|
+
"۹": "9",
|
|
1139
|
+
// Bengali numerals (used in Bangladesh, India): ০১২৩৪৫৬৭৮৯
|
|
1140
|
+
"০": "0",
|
|
1141
|
+
"১": "1",
|
|
1142
|
+
"২": "2",
|
|
1143
|
+
"৩": "3",
|
|
1144
|
+
"৪": "4",
|
|
1145
|
+
"৫": "5",
|
|
1146
|
+
"৬": "6",
|
|
1147
|
+
"৭": "7",
|
|
1148
|
+
"৮": "8",
|
|
1149
|
+
"৯": "9"
|
|
1150
|
+
};
|
|
1151
|
+
return i.split("").map((t) => e[t] ?? t).join("");
|
|
1152
|
+
}
|
|
1098
1153
|
handleInput(i) {
|
|
1099
1154
|
if (this.disabled) return;
|
|
1100
|
-
const e = i.target, t = this.inputValue;
|
|
1101
|
-
|
|
1155
|
+
const e = i.target, t = e.selectionStart ?? 0, s = this.inputValue, r = e.value, o = this.normalizeNumerals(r);
|
|
1156
|
+
o !== r && (e.value = o, requestAnimationFrame(() => {
|
|
1157
|
+
e.setSelectionRange(t, t);
|
|
1158
|
+
})), this.inputValue = o, this.touched = !0, this.showNationalAddressIcon && (this.showNationalAddressIcon = !1), this.mode === "form" && (this.validationError && (this.validationError = null), this.selectedId = null, this._internals.setFormValue(this.inputValue || null), this.validate()), this.errors && this.errors.length > 0 && (this.errors = []), this.inputValue.trim().length >= this.minChars && (this.isLoading = !0), this.debouncedFetch(this.inputValue), this._value = this.inputValue, this.requestUpdate("value", s), this.dispatchEvent(new CustomEvent("input", {
|
|
1102
1159
|
detail: { value: this.inputValue },
|
|
1103
1160
|
bubbles: !0,
|
|
1104
1161
|
composed: !0
|
|
@@ -1235,7 +1292,7 @@ let d = class extends T {
|
|
|
1235
1292
|
"with-national-icon": this.showNationalAddressIcon
|
|
1236
1293
|
}, t = {
|
|
1237
1294
|
required: this.mode === "form" && this.required
|
|
1238
|
-
}, s =
|
|
1295
|
+
}, s = q(this.language), r = this.dir === "auto" ? Ge(this.language) ? "rtl" : "ltr" : this.dir, o = this.placeholder || s.placeholder, a = this.name || "salla-address-search";
|
|
1239
1296
|
return g`
|
|
1240
1297
|
<div class="wrapper ${this.className}" part="wrapper" dir="${r}">
|
|
1241
1298
|
<div class="input-container" part="input-container">
|
|
@@ -1905,7 +1962,7 @@ export {
|
|
|
1905
1962
|
je as debounce,
|
|
1906
1963
|
We as generateSessionToken,
|
|
1907
1964
|
Ke as getCountryCode,
|
|
1908
|
-
|
|
1965
|
+
q as getTranslations,
|
|
1909
1966
|
Ge as isRTL,
|
|
1910
1967
|
tt as parseHighlight,
|
|
1911
1968
|
et as throttle
|
package/package.json
CHANGED
|
@@ -14,11 +14,6 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
|
-
"scripts": {
|
|
18
|
-
"dev": "vite",
|
|
19
|
-
"build": "tsc --emitDeclarationOnly && vite build",
|
|
20
|
-
"preview": "vite preview"
|
|
21
|
-
},
|
|
22
17
|
"keywords": [
|
|
23
18
|
"web-component",
|
|
24
19
|
"lit",
|
|
@@ -37,5 +32,10 @@
|
|
|
37
32
|
"typescript": "^5.9.3",
|
|
38
33
|
"vite": "^7.3.1"
|
|
39
34
|
},
|
|
40
|
-
"version": "1.0
|
|
41
|
-
|
|
35
|
+
"version": "1.1.0",
|
|
36
|
+
"scripts": {
|
|
37
|
+
"dev": "vite",
|
|
38
|
+
"build": "tsc --emitDeclarationOnly && vite build",
|
|
39
|
+
"preview": "vite preview"
|
|
40
|
+
}
|
|
41
|
+
}
|