@salla.sa/ui-address-autocomplete-widget 1.1.3 → 1.2.1

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.
Files changed (2) hide show
  1. package/dist/index.js +78 -65
  2. package/package.json +8 -3
package/dist/index.js CHANGED
@@ -919,6 +919,71 @@ let d = class extends C {
919
919
  cancelPendingRequest() {
920
920
  this.abortController && (this.abortController.abort(), this.abortController = null);
921
921
  }
922
+ isSaudiFormMode() {
923
+ return this.mode === "form" && this.country !== null && this.country.length === 1 && this.country[0].toLowerCase() === "sa";
924
+ }
925
+ getWhatsAppLink() {
926
+ const t = "966112898888", e = encodeURIComponent("العنوان الوطني");
927
+ return `https://wa.me/${t}?text=${e}`;
928
+ }
929
+ renderWhatsAppIcon() {
930
+ return g`
931
+ <svg class="whatsapp-icon" viewBox="0 0 24 24" fill="currentColor" part="whatsapp-icon">
932
+ <path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/>
933
+ </svg>
934
+ `;
935
+ }
936
+ getSaudiHelpTextContent() {
937
+ return {
938
+ helpText: this.language === "ar" ? "لا تعرف العنوان الوطني؟" : "Don't know your national address?",
939
+ linkText: this.language === "ar" ? "احصل على العنوان الوطني عبر الواتساب" : "Get your national address via WhatsApp"
940
+ };
941
+ }
942
+ renderSaudiFriendlyError() {
943
+ const t = this.inputValue && this.inputValue.trim().length > 0;
944
+ let e, i;
945
+ t ? (e = "العنوان الوطني المختصر غير صحيح (الصيغة: AAAA1234). يمكنك الحصول عليه بسهولة", i = "The short national address format is incorrect (format: AAAA1234). You can easily get it") : (e = "العنوان الوطني المختصر مطلوب. يمكنك الحصول عليه بسهولة", i = "The short national address is required. You can easily get it");
946
+ const r = "عبر الواتساب (اضغط هنا)", s = "via WhatsApp (click here)", o = "أو ابحث أعلاه", a = "or search above", n = this.language === "ar" ? e : i, l = this.language === "ar" ? r : s, m = this.language === "ar" ? o : a;
947
+ return g`
948
+ <span>
949
+ ${n}
950
+ <a
951
+ href="${this.getWhatsAppLink()}"
952
+ target="_blank"
953
+ rel="noopener noreferrer"
954
+ class="whatsapp-link-inline"
955
+ part="whatsapp-link"
956
+ >
957
+ ${this.renderWhatsAppIcon()}
958
+ ${l}
959
+ </a>
960
+ ${m}
961
+ </span>
962
+ `;
963
+ }
964
+ renderSaudiHelpText() {
965
+ if (!this.isSaudiFormMode() || this.validationError || this.errors && this.errors.length > 0)
966
+ return "";
967
+ const t = "لا تعرف العنوان الوطني؟ احصل عليه بسهولة", e = "Don't know your national address? Get it easily", i = "عبر الواتساب (اضغط هنا)", r = "via WhatsApp (click here)", s = "أو ابحث أعلاه", o = "or search above", a = this.language === "ar" ? t : e, n = this.language === "ar" ? i : r, l = this.language === "ar" ? s : o;
968
+ return g`
969
+ <div class="help-text" part="help-text">
970
+ <span>
971
+ ${a}
972
+ <a
973
+ href="${this.getWhatsAppLink()}"
974
+ target="_blank"
975
+ rel="noopener noreferrer"
976
+ class="whatsapp-link-inline"
977
+ part="whatsapp-link"
978
+ >
979
+ ${this.renderWhatsAppIcon()}
980
+ ${n}
981
+ </a>
982
+ ${l}
983
+ </span>
984
+ </div>
985
+ `;
986
+ }
922
987
  async fetchPredictions(t) {
923
988
  if (!t.trim()) {
924
989
  this.predictions = [], this.isOpen = !1, this.isLoading = !1;
@@ -991,6 +1056,11 @@ let d = class extends C {
991
1056
  this.isLoading = !1;
992
1057
  }
993
1058
  }
1059
+ /**
1060
+ * Validates the selected address using the provided callback
1061
+ * @param place - The place details to validate
1062
+ * @returns Promise resolving to validation result
1063
+ */
994
1064
  async validateAddress(t) {
995
1065
  try {
996
1066
  if (!t || !t.formatted_address)
@@ -1007,74 +1077,14 @@ let d = class extends C {
1007
1077
  return console.error("Error validating address:", e), this.terminateSession(), null;
1008
1078
  }
1009
1079
  }
1080
+ /**
1081
+ * Gets validation support information for a place
1082
+ * @param place - The place details to check
1083
+ * @returns ValidationSupport object indicating what validation is supported
1084
+ */
1010
1085
  getValidationSupport(t) {
1011
1086
  return ne(t, this.country);
1012
1087
  }
1013
- isSaudiFormMode() {
1014
- return this.mode === "form" && this.country !== null && this.country.length === 1 && this.country[0].toLowerCase() === "sa";
1015
- }
1016
- getWhatsAppLink() {
1017
- const t = "966112898888", e = encodeURIComponent("العنوان الوطني");
1018
- return `https://wa.me/${t}?text=${e}`;
1019
- }
1020
- renderWhatsAppIcon() {
1021
- return g`
1022
- <svg class="whatsapp-icon" viewBox="0 0 24 24" fill="currentColor" part="whatsapp-icon">
1023
- <path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/>
1024
- </svg>
1025
- `;
1026
- }
1027
- getSaudiHelpTextContent() {
1028
- return {
1029
- helpText: this.language === "ar" ? "لا تعرف العنوان الوطني؟" : "Don't know your national address?",
1030
- linkText: this.language === "ar" ? "احصل على العنوان الوطني عبر الواتساب" : "Get your national address via WhatsApp"
1031
- };
1032
- }
1033
- renderSaudiFriendlyError() {
1034
- const t = this.inputValue && this.inputValue.trim().length > 0;
1035
- let e, i;
1036
- t ? (e = "العنوان الوطني المختصر غير صحيح (الصيغة: AAAA1234). يمكنك الحصول عليه بسهولة", i = "The short national address format is incorrect (format: AAAA1234). You can easily get it") : (e = "العنوان الوطني المختصر مطلوب. يمكنك الحصول عليه بسهولة", i = "The short national address is required. You can easily get it");
1037
- const r = "عبر الواتساب (اضغط هنا)", s = "via WhatsApp (click here)", o = "أو ابحث أعلاه", a = "or search above", n = this.language === "ar" ? e : i, l = this.language === "ar" ? r : s, m = this.language === "ar" ? o : a;
1038
- return g`
1039
- <span>
1040
- ${n}
1041
- <a
1042
- href="${this.getWhatsAppLink()}"
1043
- target="_blank"
1044
- rel="noopener noreferrer"
1045
- class="whatsapp-link-inline"
1046
- part="whatsapp-link"
1047
- >
1048
- ${this.renderWhatsAppIcon()}
1049
- ${l}
1050
- </a>
1051
- ${m}
1052
- </span>
1053
- `;
1054
- }
1055
- renderSaudiHelpText() {
1056
- if (!this.isSaudiFormMode() || this.validationError || this.errors && this.errors.length > 0)
1057
- return "";
1058
- const t = "لا تعرف العنوان الوطني؟ احصل عليه بسهولة", e = "Don't know your national address? Get it easily", i = "عبر الواتساب (اضغط هنا)", r = "via WhatsApp (click here)", s = "أو ابحث أعلاه", o = "or search above", a = this.language === "ar" ? t : e, n = this.language === "ar" ? i : r, l = this.language === "ar" ? s : o;
1059
- return g`
1060
- <div class="help-text" part="help-text">
1061
- <span>
1062
- ${a}
1063
- <a
1064
- href="${this.getWhatsAppLink()}"
1065
- target="_blank"
1066
- rel="noopener noreferrer"
1067
- class="whatsapp-link-inline"
1068
- part="whatsapp-link"
1069
- >
1070
- ${this.renderWhatsAppIcon()}
1071
- ${n}
1072
- </a>
1073
- ${l}
1074
- </span>
1075
- </div>
1076
- `;
1077
- }
1078
1088
  checkValidity() {
1079
1089
  return this.validate();
1080
1090
  }
@@ -1087,6 +1097,9 @@ let d = class extends C {
1087
1097
  composed: !0
1088
1098
  })), t;
1089
1099
  }
1100
+ /**
1101
+ * Resets the component to its initial state
1102
+ */
1090
1103
  reset() {
1091
1104
  this.inputValue = "", this.selectedId = null, this.validationError = null, this.errors = [], this.touched = !1, this.predictions = [], this.isOpen = !1, this.error = null, this.showNationalAddressIcon = !1, this.mode === "form" && (this._internals.setFormValue(null), this._internals.setValidity({}));
1092
1105
  }
package/package.json CHANGED
@@ -28,14 +28,19 @@
28
28
  "lit": "^3.3.2"
29
29
  },
30
30
  "devDependencies": {
31
+ "@custom-elements-manifest/analyzer": "^0.11.0",
31
32
  "@types/node": "^25.0.10",
32
33
  "typescript": "^5.9.3",
33
34
  "vite": "^7.3.1"
34
35
  },
35
- "version": "1.1.3",
36
+ "customElements": "custom-elements.json",
37
+ "version": "1.2.1",
36
38
  "scripts": {
37
39
  "dev": "vite",
38
- "build": "tsc --emitDeclarationOnly && vite build",
39
- "preview": "vite preview"
40
+ "build": "tsc --emitDeclarationOnly && vite build --config vite.config.ts",
41
+ "build:scoped": "tsc --emitDeclarationOnly && vite build --config vite.config.ts",
42
+ "preview": "vite preview",
43
+ "analyze": "cem analyze --litelement",
44
+ "docs": "cem analyze --litelement"
40
45
  }
41
46
  }