@sanvika/auth 2.10.0 → 2.10.2

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 +231 -66
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -39,6 +39,11 @@ var CLIENT_MOBILE_POLICIES = Object.freeze({
39
39
  format: "IN_10",
40
40
  defaultCountryCode: "91",
41
41
  allowedDialCodes: ["91"]
42
+ },
43
+ /** SuperAdmin panel — E.164 digits-only SSOT; must match User.mobile exactly (no IN_10 alias lookup). */
44
+ ADMIN_E164: {
45
+ format: "E164",
46
+ defaultCountryCode: "91"
42
47
  }
43
48
  });
44
49
 
@@ -162,20 +167,6 @@ function normalizeMobileWithPolicy(raw, policy = DEFAULT_MOBILE_POLICY) {
162
167
  function isValidMobileWithPolicy(raw, policy = DEFAULT_MOBILE_POLICY) {
163
168
  return normalizeMobileWithPolicy(raw, policy) != null;
164
169
  }
165
- function getMobileLookupValues(normalized, policy = DEFAULT_MOBILE_POLICY) {
166
- if (!normalized) return [];
167
- const p = mergeMobilePolicy(policy);
168
- const values = /* @__PURE__ */ new Set([normalized]);
169
- if (p.format !== MOBILE_FORMAT.IN_10) {
170
- if (normalized.startsWith("91") && normalized.length === 12) {
171
- values.add(normalized.slice(2));
172
- }
173
- if (/^\d{10}$/.test(normalized)) {
174
- values.add(`91${normalized}`);
175
- }
176
- }
177
- return [...values];
178
- }
179
170
  function formatMobileForDisplay(normalized, policy = DEFAULT_MOBILE_POLICY) {
180
171
  if (!normalized) return "";
181
172
  const p = mergeMobilePolicy(policy);
@@ -213,13 +204,10 @@ function toIndiaE164FromLegacyIn10(mobile) {
213
204
  return `91${d}`;
214
205
  }
215
206
  function mobilesMatchIdentity(stored, candidate) {
216
- const policy = { format: MOBILE_FORMAT.E164 };
217
207
  const a = digitsOnly(stored);
218
208
  const b = digitsOnly(candidate);
219
209
  if (!a || !b) return false;
220
- if (a === b) return true;
221
- const aliasA = new Set(getMobileLookupValues(a, policy));
222
- return getMobileLookupValues(b, policy).some((v) => aliasA.has(v));
210
+ return a === b;
223
211
  }
224
212
 
225
213
  // authFlow.js
@@ -290,7 +278,8 @@ async function checkMobile({
290
278
  mobile: normalized,
291
279
  deviceId,
292
280
  clientId,
293
- ...callbackUrl ? { callbackUrl } : {}
281
+ ...callbackUrl ? { callbackUrl } : {},
282
+ ...mobilePolicy ? { mobilePolicy: mergeMobilePolicy(mobilePolicy) } : {}
294
283
  })
295
284
  });
296
285
  const data = await res.json();
@@ -320,6 +309,9 @@ async function postLogin({
320
309
  if (password) {
321
310
  body.password = password;
322
311
  }
312
+ if (mobilePolicy) {
313
+ body.mobilePolicy = mergeMobilePolicy(mobilePolicy);
314
+ }
323
315
  const res = await fetch(authApiUrl(AUTH_API.LOGIN, authBaseUrl), {
324
316
  method: "POST",
325
317
  headers: { "Content-Type": "application/json" },
@@ -882,11 +874,11 @@ function SanvikaAccountButton(props) {
882
874
  }
883
875
 
884
876
  // SanvikaAdminLogin.jsx
885
- import { useState as useState3, useEffect as useEffect3 } from "react";
877
+ import { useState as useState4, useEffect as useEffect4 } from "react";
886
878
  import { useRouter } from "next/navigation";
887
879
 
888
880
  // MobilePolicyPhoneInput.jsx
889
- import PhoneInput, { formatPhoneNumberIntl } from "react-phone-number-input";
881
+ import PhoneInput from "react-phone-number-input";
890
882
  import flags from "react-phone-number-input/flags";
891
883
  import en from "react-phone-number-input/locale/en.json";
892
884
  import { parsePhoneNumber } from "libphonenumber-js/min";
@@ -924,6 +916,12 @@ function isCountryLocked(config) {
924
916
  const list = countriesForPolicy(config);
925
917
  return Array.isArray(list) && list.length === 1;
926
918
  }
919
+ function countryOptionsOrderForPolicy(config) {
920
+ const list = countriesForPolicy(config);
921
+ if (Array.isArray(list) && list.length <= 1) return void 0;
922
+ const top = defaultCountryForPolicy(config);
923
+ return top ? [top, "|"] : void 0;
924
+ }
927
925
  function toPhoneInputValue(raw, config) {
928
926
  if (!raw) return void 0;
929
927
  const s = String(raw).trim();
@@ -934,14 +932,179 @@ function toPhoneInputValue(raw, config) {
934
932
  return `+${digits}`;
935
933
  }
936
934
 
935
+ // PolicySearchableCountrySelect.jsx
936
+ import { useEffect as useEffect3, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
937
+ import { getCountryCallingCode } from "react-phone-number-input";
938
+
939
+ // unicodeCountryFlag.js
940
+ function unicodeCountryFlag(countryCode) {
941
+ if (!countryCode || countryCode === "ZZ" || countryCode.length !== 2) return "";
942
+ const upper = countryCode.toUpperCase();
943
+ if (!/^[A-Z]{2}$/.test(upper)) return "";
944
+ return String.fromCodePoint(
945
+ ...[...upper].map((char) => 127397 + char.charCodeAt(0))
946
+ );
947
+ }
948
+
949
+ // PolicySearchableCountrySelect.jsx
950
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
951
+ function dialCodeFor(country) {
952
+ if (!country) return "";
953
+ try {
954
+ return `+${getCountryCallingCode(country)}`;
955
+ } catch {
956
+ return "";
957
+ }
958
+ }
959
+ function countryWords(label) {
960
+ return String(label || "").toLowerCase().split(/[\s,().-]+/).filter(Boolean);
961
+ }
962
+ function matchScore(label, q, code, dialDigits, qDigits) {
963
+ const normalized = String(label || "").toLowerCase();
964
+ if (normalized.startsWith(q)) return 0;
965
+ if (countryWords(label).some((word) => word.startsWith(q))) return 1;
966
+ if (code.startsWith(q)) return 2;
967
+ if (qDigits && dialDigits.startsWith(qDigits)) return 3;
968
+ return -1;
969
+ }
970
+ function PolicySearchableCountrySelect({
971
+ value,
972
+ onChange,
973
+ options,
974
+ disabled,
975
+ readOnly
976
+ }) {
977
+ const [open, setOpen] = useState3(false);
978
+ const [query, setQuery] = useState3("");
979
+ const rootRef = useRef2(null);
980
+ const searchRef = useRef2(null);
981
+ const selectable = useMemo2(
982
+ () => options.filter((o) => !o.divider && o.value),
983
+ [options]
984
+ );
985
+ const filtered = useMemo2(() => {
986
+ const q = query.trim().toLowerCase();
987
+ if (!q) return selectable;
988
+ const qDigits = q.replace(/\D/g, "");
989
+ return selectable.map((o) => ({
990
+ option: o,
991
+ score: matchScore(
992
+ o.label,
993
+ q,
994
+ (o.value || "").toLowerCase(),
995
+ dialCodeFor(o.value).replace(/\D/g, ""),
996
+ qDigits
997
+ )
998
+ })).filter((row) => row.score >= 0).sort((a, b) => a.score - b.score || a.option.label.localeCompare(b.option.label)).map((row) => row.option);
999
+ }, [query, selectable]);
1000
+ useEffect3(() => {
1001
+ if (!open) return void 0;
1002
+ const onDoc = (event) => {
1003
+ if (rootRef.current && !rootRef.current.contains(event.target)) {
1004
+ setOpen(false);
1005
+ }
1006
+ };
1007
+ document.addEventListener("click", onDoc);
1008
+ return () => document.removeEventListener("click", onDoc);
1009
+ }, [open]);
1010
+ useEffect3(() => {
1011
+ if (!open) return;
1012
+ setQuery("");
1013
+ requestAnimationFrame(() => {
1014
+ var _a;
1015
+ return (_a = searchRef.current) == null ? void 0 : _a.focus();
1016
+ });
1017
+ }, [open]);
1018
+ const locked = disabled || readOnly;
1019
+ const flag = value ? unicodeCountryFlag(value) : "\u{1F310}";
1020
+ const dial = dialCodeFor(value);
1021
+ const pick = (code) => {
1022
+ if (!code || code === value) {
1023
+ setOpen(false);
1024
+ setQuery("");
1025
+ return;
1026
+ }
1027
+ onChange(code);
1028
+ setOpen(false);
1029
+ setQuery("");
1030
+ };
1031
+ return /* @__PURE__ */ jsx3("div", { className: "PhoneInputCountry", children: /* @__PURE__ */ jsxs2("div", { className: "sa-country-picker", ref: rootRef, children: [
1032
+ /* @__PURE__ */ jsxs2(
1033
+ "button",
1034
+ {
1035
+ type: "button",
1036
+ className: "sa-country-picker__trigger",
1037
+ disabled: locked,
1038
+ "aria-expanded": open,
1039
+ "aria-haspopup": "listbox",
1040
+ "aria-label": value ? `Country ${value}` : "Select country",
1041
+ onClick: (event) => {
1042
+ event.stopPropagation();
1043
+ if (!locked) setOpen((v) => !v);
1044
+ },
1045
+ children: [
1046
+ /* @__PURE__ */ jsx3("span", { className: "sa-country-picker__flag", "aria-hidden": "true", children: flag }),
1047
+ dial ? /* @__PURE__ */ jsx3("span", { className: "sa-country-picker__dial", children: dial }) : null,
1048
+ !locked ? /* @__PURE__ */ jsx3("span", { className: "sa-country-picker__chev", "aria-hidden": "true", children: "\u25BE" }) : null
1049
+ ]
1050
+ }
1051
+ ),
1052
+ open && !locked ? /* @__PURE__ */ jsxs2(
1053
+ "div",
1054
+ {
1055
+ className: "sa-country-picker__panel",
1056
+ role: "listbox",
1057
+ onMouseDown: (event) => event.stopPropagation(),
1058
+ children: [
1059
+ /* @__PURE__ */ jsx3(
1060
+ "input",
1061
+ {
1062
+ ref: searchRef,
1063
+ type: "search",
1064
+ className: "sa-country-picker__search",
1065
+ placeholder: "Search country",
1066
+ value: query,
1067
+ onChange: (e) => setQuery(e.target.value),
1068
+ "aria-label": "Search country",
1069
+ autoComplete: "off"
1070
+ }
1071
+ ),
1072
+ /* @__PURE__ */ jsxs2("ul", { className: "sa-country-picker__list", children: [
1073
+ filtered.map((o) => /* @__PURE__ */ jsx3("li", { children: /* @__PURE__ */ jsxs2(
1074
+ "button",
1075
+ {
1076
+ type: "button",
1077
+ role: "option",
1078
+ "aria-selected": o.value === value,
1079
+ className: `sa-country-picker__option${o.value === value ? " sa-country-picker__option--active" : ""}`,
1080
+ onMouseDown: (event) => {
1081
+ event.preventDefault();
1082
+ event.stopPropagation();
1083
+ pick(o.value);
1084
+ },
1085
+ children: [
1086
+ /* @__PURE__ */ jsx3("span", { className: "sa-country-picker__option-flag", "aria-hidden": "true", children: unicodeCountryFlag(o.value) }),
1087
+ /* @__PURE__ */ jsx3("span", { className: "sa-country-picker__name", children: o.label }),
1088
+ /* @__PURE__ */ jsx3("span", { className: "sa-country-picker__code", children: dialCodeFor(o.value) })
1089
+ ]
1090
+ }
1091
+ ) }, o.value)),
1092
+ !filtered.length ? /* @__PURE__ */ jsx3("li", { className: "sa-country-picker__empty", children: "No matches" }) : null
1093
+ ] })
1094
+ ]
1095
+ }
1096
+ ) : null
1097
+ ] }) });
1098
+ }
1099
+
937
1100
  // MobilePolicyPhoneInput.jsx
938
1101
  import "react-phone-number-input/style.css";
939
1102
 
940
1103
  // MobilePolicyPhoneInput.css
941
- styleInject(".sa-phone-field {\n margin-bottom: 16px;\n}\n.sa-phone-input {\n display: block;\n}\n.sa-phone-input .PhoneInput {\n display: flex;\n align-items: stretch;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid #dddddd;\n background: #ffffff;\n}\n.sa-phone-input--dark .PhoneInput {\n border-color: #333333;\n background: #222222;\n}\n.sa-phone-input .PhoneInputCountry {\n align-self: stretch;\n display: flex;\n align-items: center;\n padding: 0 10px;\n margin: 0;\n border-right: 1px solid #dddddd;\n background: #f5f5f5;\n}\n.sa-phone-input--dark .PhoneInputCountry {\n border-right-color: #333333;\n background: #2a2a2a;\n}\n.sa-phone-input .PhoneInputCountrySelect {\n font-size: 14px;\n cursor: pointer;\n color: #222222;\n max-width: 120px;\n}\n.sa-phone-input--dark .PhoneInputCountrySelect {\n color: #eeeeee;\n background: #2a2a2a;\n}\n.sa-phone-input .PhoneInputCountrySelect:disabled {\n cursor: default;\n opacity: 0.85;\n}\n.sa-phone-input .PhoneInputCountryIcon {\n width: 1.5em;\n height: 1em;\n box-shadow: none;\n border: none;\n}\n.sa-phone-input .PhoneInputCountryIcon--border {\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);\n}\n.sa-phone-input .PhoneInputInput {\n flex: 1;\n min-width: 0;\n border: none;\n outline: none;\n padding: 10px 12px;\n font-size: 15px;\n background: transparent;\n color: #222222;\n}\n.sa-phone-input--dark .PhoneInputInput {\n color: #ffffff;\n}\n.sa-phone-input .PhoneInputInput::placeholder {\n color: #999999;\n}\n.sa-phone-input--dark .PhoneInputInput::placeholder {\n color: #666666;\n}\n.sa-phone-preview {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px 10px;\n margin-top: 8px;\n padding: 8px 10px;\n border-radius: 6px;\n font-size: 12px;\n background: #f0f7ff;\n border: 1px solid #cce4ff;\n}\n.sa-phone-preview--dark {\n background: #1a2433;\n border-color: #2a3f5f;\n}\n.sa-phone-preview__label {\n font-weight: 600;\n color: #555555;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n font-size: 10px;\n}\n.sa-phone-preview--dark .sa-phone-preview__label {\n color: #8899aa;\n}\n.sa-phone-preview__value {\n color: #0984e3;\n font-weight: 500;\n}\n.sa-phone-preview--dark .sa-phone-preview__value {\n color: #88c5ff;\n}\n.sa-phone-preview__e164 {\n font-family:\n ui-monospace,\n SFMono-Regular,\n Menlo,\n monospace;\n color: #333333;\n background: rgba(0, 0, 0, 0.05);\n padding: 2px 6px;\n border-radius: 4px;\n}\n.sa-phone-preview--dark .sa-phone-preview__e164 {\n color: #cccccc;\n background: rgba(255, 255, 255, 0.06);\n}\n.sa-phone-input--modal .PhoneInputCountrySelect {\n max-width: 100px;\n}\n");
1104
+ styleInject(".sa-phone-field {\n margin-bottom: 16px;\n}\n.sa-phone-input {\n display: block;\n}\n.sa-phone-input .PhoneInput {\n display: flex;\n align-items: stretch;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid #dddddd;\n background: #ffffff;\n}\n.sa-phone-input--searchable-country .PhoneInput {\n overflow: visible;\n}\n.sa-phone-input--dark .PhoneInput {\n border-color: #333333;\n background: #222222;\n}\n.sa-phone-input .PhoneInputCountry {\n position: relative;\n flex: 0 0 auto;\n align-self: stretch;\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 0;\n min-width: 5.25rem;\n max-width: 6.75rem;\n border-right: 1px solid #dddddd;\n background: #f5f5f5;\n}\n.sa-phone-input--dark .PhoneInputCountry {\n border-right-color: #333333;\n background: #2a2a2a;\n}\n.sa-phone-input--searchable-country .PhoneInputCountryIcon,\n.sa-phone-input--searchable-country .PhoneInputCountryIconUnicode,\n.sa-phone-input--searchable-country .PhoneInputCountrySelectArrow {\n display: none !important;\n}\n.sa-phone-input .PhoneInputInput {\n flex: 1 1 auto;\n min-width: 0;\n width: 100%;\n border: none;\n outline: none;\n padding: 10px 12px;\n font-size: 15px;\n background: transparent;\n color: #222222;\n}\n.sa-phone-input--dark .PhoneInputInput {\n color: #ffffff;\n}\n.sa-phone-input .PhoneInputInput::placeholder {\n color: #999999;\n}\n.sa-phone-input--dark .PhoneInputInput::placeholder {\n color: #666666;\n}\n.sa-country-picker {\n position: relative;\n width: 100%;\n height: 100%;\n min-height: 42px;\n}\n.sa-country-picker__trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 4px;\n width: 100%;\n height: 100%;\n min-height: 42px;\n padding: 0 8px;\n margin: 0;\n border: none;\n background: transparent;\n cursor: pointer;\n color: inherit;\n font: inherit;\n}\n.sa-country-picker__trigger:disabled {\n cursor: default;\n opacity: 0.65;\n}\n.sa-country-picker__flag {\n font-size: 1.15rem;\n line-height: 1;\n flex-shrink: 0;\n}\n.sa-country-picker__dial {\n font-size: 13px;\n font-weight: 600;\n white-space: nowrap;\n flex-shrink: 0;\n}\n.sa-country-picker__chev {\n font-size: 10px;\n opacity: 0.7;\n flex-shrink: 0;\n margin-left: 1px;\n}\n.sa-country-picker__panel {\n position: absolute;\n top: calc(100% + 4px);\n left: 0;\n z-index: 50;\n width: min(20rem, calc(100vw - 2rem));\n max-height: min(20rem, 55vh);\n display: flex;\n flex-direction: column;\n border-radius: 10px;\n border: 1px solid #dddddd;\n background: #ffffff;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);\n overflow: hidden;\n}\n.sa-phone-input--dark .sa-country-picker__panel {\n border-color: #444444;\n background: #1e1e1e;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);\n}\n.sa-country-picker__search {\n flex-shrink: 0;\n width: 100%;\n padding: 10px 12px;\n border: none;\n border-bottom: 1px solid #eeeeee;\n outline: none;\n font-size: 14px;\n background: #fafafa;\n color: #222222;\n}\n.sa-phone-input--dark .sa-country-picker__search {\n border-bottom-color: #333333;\n background: #252525;\n color: #ffffff;\n}\n.sa-country-picker__list {\n list-style: none;\n margin: 0;\n padding: 4px 0;\n overflow-y: auto;\n flex: 1;\n min-height: 0;\n}\n.sa-country-picker__option {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n padding: 8px 12px;\n border: none;\n background: transparent;\n cursor: pointer;\n text-align: left;\n font-size: 14px;\n color: #222222;\n}\n.sa-phone-input--dark .sa-country-picker__option {\n color: #eeeeee;\n}\n.sa-country-picker__option:hover,\n.sa-country-picker__option--active {\n background: #f0f4ff;\n}\n.sa-phone-input--dark .sa-country-picker__option:hover,\n.sa-phone-input--dark .sa-country-picker__option--active {\n background: #2a3344;\n}\n.sa-country-picker__option-flag {\n font-size: 1.1rem;\n line-height: 1;\n flex-shrink: 0;\n}\n.sa-country-picker__name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.sa-country-picker__code {\n flex-shrink: 0;\n font-size: 12px;\n font-weight: 600;\n color: #666666;\n}\n.sa-phone-input--dark .sa-country-picker__code {\n color: #999999;\n}\n.sa-country-picker__empty {\n padding: 12px;\n font-size: 13px;\n color: #888888;\n text-align: center;\n}\n.sa-phone-preview {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px 10px;\n margin-top: 8px;\n padding: 8px 10px;\n border-radius: 6px;\n font-size: 12px;\n background: #f0f7ff;\n border: 1px solid #cce4ff;\n}\n.sa-phone-preview--dark {\n background: #1a2433;\n border-color: #2a3f5f;\n}\n.sa-phone-preview__label {\n font-weight: 600;\n color: #555555;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n font-size: 10px;\n}\n.sa-phone-preview--dark .sa-phone-preview__label {\n color: #8899aa;\n}\n.sa-phone-preview__value {\n color: #0984e3;\n font-weight: 500;\n}\n.sa-phone-preview--dark .sa-phone-preview__value {\n color: #88c5ff;\n}\n.sa-phone-preview__e164 {\n font-family:\n ui-monospace,\n SFMono-Regular,\n Menlo,\n monospace;\n color: #333333;\n background: rgba(0, 0, 0, 0.05);\n padding: 2px 6px;\n border-radius: 4px;\n}\n.sa-phone-preview--dark .sa-phone-preview__e164 {\n color: #cccccc;\n background: rgba(255, 255, 255, 0.06);\n}\n");
942
1105
 
943
1106
  // MobilePolicyPhoneInput.jsx
944
- import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1107
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
945
1108
  function MobilePolicyPhoneInput({
946
1109
  config,
947
1110
  value,
@@ -949,53 +1112,58 @@ function MobilePolicyPhoneInput({
949
1112
  theme = "dark",
950
1113
  inputRef,
951
1114
  id = "mobile-phone-input",
952
- placeholder = "Enter phone number"
1115
+ placeholder = "Enter phone number",
1116
+ showPreview = true
953
1117
  }) {
954
1118
  const policy = mergeMobilePolicy(config);
955
1119
  const countries = countriesForPolicy(config);
956
1120
  const defaultCountry = defaultCountryForPolicy(config);
957
1121
  const countryLocked = isCountryLocked(config);
958
- let intlFormatted = "";
959
- let e164Digits = "";
1122
+ const countryOrder = countryOptionsOrderForPolicy(config);
1123
+ let e164Display = "";
960
1124
  if (value) {
961
1125
  try {
962
- intlFormatted = formatPhoneNumberIntl(value) || value;
963
1126
  const parsed = parsePhoneNumber(value);
964
1127
  if (parsed == null ? void 0 : parsed.isValid()) {
965
- e164Digits = parsed.number.replace("+", "");
1128
+ e164Display = parsed.number;
966
1129
  } else {
967
- e164Digits = normalizeMobileWithPolicy(value, policy) || String(value).replace(/\D/g, "");
1130
+ const digits = normalizeMobileWithPolicy(value, policy) || String(value).replace(/\D/g, "");
1131
+ e164Display = digits ? `+${digits}` : "";
968
1132
  }
969
1133
  } catch {
970
- intlFormatted = value;
1134
+ e164Display = "";
971
1135
  }
972
1136
  }
973
- return /* @__PURE__ */ jsxs2("div", { className: "sa-phone-field", children: [
974
- /* @__PURE__ */ jsx3(
1137
+ return /* @__PURE__ */ jsxs3("div", { className: "sa-phone-field", children: [
1138
+ /* @__PURE__ */ jsx4(
975
1139
  "div",
976
1140
  {
977
- className: `sa-phone-input sa-phone-input--${theme}`,
1141
+ className: `sa-phone-input sa-phone-input--${theme} sa-phone-input--searchable-country`,
978
1142
  "data-theme": theme,
979
- children: /* @__PURE__ */ jsx3(
1143
+ children: /* @__PURE__ */ jsx4(
980
1144
  PhoneInput,
981
1145
  {
982
1146
  id,
983
- international: true,
1147
+ international: false,
984
1148
  countryCallingCodeEditable: false,
985
1149
  defaultCountry,
986
1150
  countries,
1151
+ countryOptionsOrder: countryOrder,
1152
+ addInternationalOption: false,
1153
+ countrySelectComponent: PolicySearchableCountrySelect,
987
1154
  flags,
988
1155
  labels: en,
989
1156
  value,
990
1157
  onChange,
991
1158
  placeholder,
992
1159
  smartCaret: true,
1160
+ inputRef,
1161
+ focusInputOnCountrySelection: Boolean(inputRef),
993
1162
  countrySelectProps: {
994
1163
  unicodeFlags: true,
995
1164
  ...countryLocked ? { disabled: true } : {}
996
1165
  },
997
1166
  numberInputProps: {
998
- ref: inputRef,
999
1167
  autoComplete: "tel",
1000
1168
  inputMode: "tel",
1001
1169
  "aria-label": "Phone number"
@@ -1004,14 +1172,10 @@ function MobilePolicyPhoneInput({
1004
1172
  )
1005
1173
  }
1006
1174
  ),
1007
- value && /* @__PURE__ */ jsxs2("div", { className: `sa-phone-preview sa-phone-preview--${theme}`, children: [
1008
- /* @__PURE__ */ jsx3("span", { className: "sa-phone-preview__label", children: "Formatted" }),
1009
- /* @__PURE__ */ jsx3("span", { className: "sa-phone-preview__value", children: intlFormatted }),
1010
- e164Digits ? /* @__PURE__ */ jsxs2(Fragment, { children: [
1011
- /* @__PURE__ */ jsx3("span", { className: "sa-phone-preview__label", children: "E.164" }),
1012
- /* @__PURE__ */ jsx3("span", { className: "sa-phone-preview__e164", children: e164Digits })
1013
- ] }) : null
1014
- ] })
1175
+ showPreview && value && e164Display ? /* @__PURE__ */ jsxs3("div", { className: `sa-phone-preview sa-phone-preview--${theme}`, children: [
1176
+ /* @__PURE__ */ jsx4("span", { className: "sa-phone-preview__label", children: "E.164" }),
1177
+ /* @__PURE__ */ jsx4("span", { className: "sa-phone-preview__e164", children: e164Display })
1178
+ ] }) : null
1015
1179
  ] });
1016
1180
  }
1017
1181
 
@@ -1071,9 +1235,9 @@ function mobilePlaceholder(config) {
1071
1235
  }
1072
1236
 
1073
1237
  // SanvikaAdminLogin.jsx
1074
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
1238
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1075
1239
  var DEVICE_ID_KEY = "sanvika_admin_device_id";
1076
- var ADMIN_MOBILE_POLICY = CLIENT_MOBILE_POLICIES.IN_10;
1240
+ var ADMIN_MOBILE_POLICY = CLIENT_MOBILE_POLICIES.ADMIN_E164;
1077
1241
  function getDeviceId() {
1078
1242
  var _a;
1079
1243
  if (typeof window === "undefined") return "";
@@ -1116,12 +1280,12 @@ function SanvikaAdminLogin({
1116
1280
  }) {
1117
1281
  const router = useRouter();
1118
1282
  const { isAuthenticated, loading, user, setAuth, clientId } = useSanvikaAuth();
1119
- const [phoneValue, setPhoneValue] = useState3(void 0);
1120
- const [password, setPassword] = useState3("");
1121
- const [error, setError] = useState3("");
1122
- const [submitting, setSubmitting] = useState3(false);
1123
- const [ready, setReady] = useState3(false);
1124
- useEffect3(() => {
1283
+ const [phoneValue, setPhoneValue] = useState4(void 0);
1284
+ const [password, setPassword] = useState4("");
1285
+ const [error, setError] = useState4("");
1286
+ const [submitting, setSubmitting] = useState4(false);
1287
+ const [ready, setReady] = useState4(false);
1288
+ useEffect4(() => {
1125
1289
  if (loading) return;
1126
1290
  if (isAuthenticated && (user == null ? void 0 : user.role) === "superadmin") {
1127
1291
  router.replace(dashboardPath);
@@ -1242,10 +1406,10 @@ function SanvikaAdminLogin({
1242
1406
  }
1243
1407
  };
1244
1408
  if (loading || !ready) {
1245
- return /* @__PURE__ */ jsx4("div", { style: S.page, children: /* @__PURE__ */ jsx4("div", { style: S.card, children: /* @__PURE__ */ jsx4("p", { style: S.subtitle, children: "Loading\u2026" }) }) });
1409
+ return /* @__PURE__ */ jsx5("div", { style: S.page, children: /* @__PURE__ */ jsx5("div", { style: S.card, children: /* @__PURE__ */ jsx5("p", { style: S.subtitle, children: "Loading\u2026" }) }) });
1246
1410
  }
1247
- return /* @__PURE__ */ jsx4("div", { style: S.page, children: /* @__PURE__ */ jsxs3("div", { style: S.card, children: [
1248
- /* @__PURE__ */ jsx4(
1411
+ return /* @__PURE__ */ jsx5("div", { style: S.page, children: /* @__PURE__ */ jsxs4("div", { style: S.card, children: [
1412
+ /* @__PURE__ */ jsx5(
1249
1413
  "button",
1250
1414
  {
1251
1415
  style: S.closeBtn,
@@ -1254,15 +1418,15 @@ function SanvikaAdminLogin({
1254
1418
  children: "\u2715"
1255
1419
  }
1256
1420
  ),
1257
- /* @__PURE__ */ jsx4("div", { style: S.logo, children: "\u{1F6E1}\uFE0F" }),
1258
- /* @__PURE__ */ jsxs3("h1", { style: S.title, children: [
1421
+ /* @__PURE__ */ jsx5("div", { style: S.logo, children: "\u{1F6E1}\uFE0F" }),
1422
+ /* @__PURE__ */ jsxs4("h1", { style: S.title, children: [
1259
1423
  serviceName,
1260
1424
  " Admin"
1261
1425
  ] }),
1262
- /* @__PURE__ */ jsx4("p", { style: S.subtitle, children: "SuperAdmin access \u2014 Sanvika Accounts SSO" }),
1263
- /* @__PURE__ */ jsxs3("form", { onSubmit: handleLogin, style: S.form, autoComplete: "off", children: [
1264
- /* @__PURE__ */ jsx4("label", { style: S.label, htmlFor: "admin-mobile-phone", children: "Mobile Number" }),
1265
- /* @__PURE__ */ jsx4(
1426
+ /* @__PURE__ */ jsx5("p", { style: S.subtitle, children: "SuperAdmin access \u2014 enter mobile with country code (E.164, as stored in Sanvika Accounts)" }),
1427
+ /* @__PURE__ */ jsxs4("form", { onSubmit: handleLogin, style: S.form, autoComplete: "off", children: [
1428
+ /* @__PURE__ */ jsx5("label", { style: S.label, htmlFor: "admin-mobile-phone", children: "Mobile Number" }),
1429
+ /* @__PURE__ */ jsx5(
1266
1430
  MobilePolicyPhoneInput,
1267
1431
  {
1268
1432
  config: ADMIN_MOBILE_POLICY,
@@ -1270,11 +1434,12 @@ function SanvikaAdminLogin({
1270
1434
  onChange: setPhoneValue,
1271
1435
  theme: "dark",
1272
1436
  id: "admin-mobile-phone",
1273
- placeholder: "Enter phone number"
1437
+ placeholder: "Include country code, e.g. +91 88002 18812",
1438
+ showPreview: true
1274
1439
  }
1275
1440
  ),
1276
- /* @__PURE__ */ jsx4("label", { style: S.label, children: "Password" }),
1277
- /* @__PURE__ */ jsx4(
1441
+ /* @__PURE__ */ jsx5("label", { style: S.label, children: "Password" }),
1442
+ /* @__PURE__ */ jsx5(
1278
1443
  "input",
1279
1444
  {
1280
1445
  type: "password",
@@ -1286,7 +1451,7 @@ function SanvikaAdminLogin({
1286
1451
  autoComplete: "new-password"
1287
1452
  }
1288
1453
  ),
1289
- /* @__PURE__ */ jsx4(
1454
+ /* @__PURE__ */ jsx5(
1290
1455
  "button",
1291
1456
  {
1292
1457
  type: "submit",
@@ -1296,7 +1461,7 @@ function SanvikaAdminLogin({
1296
1461
  }
1297
1462
  )
1298
1463
  ] }),
1299
- error && /* @__PURE__ */ jsx4("p", { style: S.error, children: error })
1464
+ error && /* @__PURE__ */ jsx5("p", { style: S.error, children: error })
1300
1465
  ] }) });
1301
1466
  }
1302
1467
  var ADMIN_LOGIN_API_URL = authApiUrl(AUTH_API.LOGIN, DEFAULT_AUTH_URL);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanvika/auth",
3
- "version": "2.10.0",
3
+ "version": "2.10.2",
4
4
  "description": "Sanvika Auth SDK — React components/hooks + server-side token verification and user proxy",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",