@rufous/ui 0.3.18 → 0.3.20
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/main.cjs +198 -2
- package/dist/main.d.cts +130 -1
- package/dist/main.d.ts +130 -1
- package/dist/main.js +182 -1
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -168,8 +168,23 @@ __export(main_exports, {
|
|
|
168
168
|
ViewIcon: () => viewIcon_default,
|
|
169
169
|
WorkItemIcon: () => workItemIcon_default,
|
|
170
170
|
Zoom: () => Zoom,
|
|
171
|
+
getAllCountries: () => getAllCountries2,
|
|
172
|
+
getCitiesByName: () => getCitiesByName,
|
|
173
|
+
getCitiesOfCountry: () => getCitiesOfCountry,
|
|
174
|
+
getCitiesOfState: () => getCitiesOfState,
|
|
175
|
+
getCityByName: () => getCityByName,
|
|
176
|
+
getCountriesByName: () => getCountriesByName,
|
|
177
|
+
getCountryByCode: () => getCountryByCode,
|
|
178
|
+
getCountryByName: () => getCountryByName,
|
|
179
|
+
getStateByCode: () => getStateByCode,
|
|
180
|
+
getStateByName: () => getStateByName,
|
|
181
|
+
getStatesByName: () => getStatesByName,
|
|
182
|
+
getStatesOfCountry: () => getStatesOfCountry,
|
|
171
183
|
transformLegacyTodos: () => transformLegacyTodos,
|
|
172
|
-
|
|
184
|
+
useCitiesSearch: () => useCitiesSearch,
|
|
185
|
+
useCountriesSearch: () => useCountriesSearch,
|
|
186
|
+
useRufousTheme: () => useRufousTheme,
|
|
187
|
+
useStatesSearch: () => useStatesSearch
|
|
173
188
|
});
|
|
174
189
|
module.exports = __toCommonJS(main_exports);
|
|
175
190
|
|
|
@@ -13616,6 +13631,172 @@ var RufousTextContent = ({ content, className, style, sx }) => {
|
|
|
13616
13631
|
}
|
|
13617
13632
|
);
|
|
13618
13633
|
};
|
|
13634
|
+
|
|
13635
|
+
// lib/utils/locationData.ts
|
|
13636
|
+
var import_country_state_city3 = require("country-state-city");
|
|
13637
|
+
var _stateNameCache = /* @__PURE__ */ new Map();
|
|
13638
|
+
function getStateNameMap(countryCode) {
|
|
13639
|
+
if (!_stateNameCache.has(countryCode)) {
|
|
13640
|
+
const map = /* @__PURE__ */ new Map();
|
|
13641
|
+
import_country_state_city3.State.getStatesOfCountry(countryCode).forEach((s2) => map.set(s2.isoCode, s2.name));
|
|
13642
|
+
_stateNameCache.set(countryCode, map);
|
|
13643
|
+
}
|
|
13644
|
+
return _stateNameCache.get(countryCode);
|
|
13645
|
+
}
|
|
13646
|
+
var _allCountriesCache = null;
|
|
13647
|
+
function getAllCountriesCached() {
|
|
13648
|
+
if (!_allCountriesCache) _allCountriesCache = import_country_state_city3.Country.getAllCountries();
|
|
13649
|
+
return _allCountriesCache;
|
|
13650
|
+
}
|
|
13651
|
+
var _allStatesCache = null;
|
|
13652
|
+
function getAllStatesCached() {
|
|
13653
|
+
if (!_allStatesCache) {
|
|
13654
|
+
const countryMap = new Map(import_country_state_city3.Country.getAllCountries().map((c) => [c.isoCode, c.name]));
|
|
13655
|
+
_allStatesCache = import_country_state_city3.State.getAllStates().map((s2) => ({
|
|
13656
|
+
...s2,
|
|
13657
|
+
countryName: countryMap.get(s2.countryCode) ?? ""
|
|
13658
|
+
}));
|
|
13659
|
+
}
|
|
13660
|
+
return _allStatesCache;
|
|
13661
|
+
}
|
|
13662
|
+
var _allCitiesCache = null;
|
|
13663
|
+
function getAllCitiesCached() {
|
|
13664
|
+
if (!_allCitiesCache) {
|
|
13665
|
+
const countryMap = new Map(import_country_state_city3.Country.getAllCountries().map((c) => [c.isoCode, c.name]));
|
|
13666
|
+
const stateMap = new Map(import_country_state_city3.State.getAllStates().map((s2) => [`${s2.countryCode}:${s2.isoCode}`, s2.name]));
|
|
13667
|
+
_allCitiesCache = import_country_state_city3.City.getAllCities().map((city) => ({
|
|
13668
|
+
...city,
|
|
13669
|
+
cityCode: city.name.slice(0, 3),
|
|
13670
|
+
countryName: countryMap.get(city.countryCode) ?? "",
|
|
13671
|
+
stateName: stateMap.get(`${city.countryCode}:${city.stateCode}`) ?? ""
|
|
13672
|
+
}));
|
|
13673
|
+
}
|
|
13674
|
+
return _allCitiesCache;
|
|
13675
|
+
}
|
|
13676
|
+
function getAllCountries2() {
|
|
13677
|
+
return getAllCountriesCached();
|
|
13678
|
+
}
|
|
13679
|
+
function getCountryByCode(isoCode) {
|
|
13680
|
+
return import_country_state_city3.Country.getCountryByCode(isoCode) ?? void 0;
|
|
13681
|
+
}
|
|
13682
|
+
function getCountryByName(name, exact = false) {
|
|
13683
|
+
const q = name.toLowerCase();
|
|
13684
|
+
return getAllCountriesCached().find(
|
|
13685
|
+
(c) => exact ? c.name.toLowerCase() === q : c.name.toLowerCase().includes(q)
|
|
13686
|
+
);
|
|
13687
|
+
}
|
|
13688
|
+
function getCountriesByName(name, exact = false) {
|
|
13689
|
+
const q = name.toLowerCase();
|
|
13690
|
+
return getAllCountriesCached().filter(
|
|
13691
|
+
(c) => exact ? c.name.toLowerCase() === q : c.name.toLowerCase().includes(q)
|
|
13692
|
+
);
|
|
13693
|
+
}
|
|
13694
|
+
function getStatesOfCountry(countryCode) {
|
|
13695
|
+
const countryName = import_country_state_city3.Country.getCountryByCode(countryCode)?.name ?? "";
|
|
13696
|
+
return import_country_state_city3.State.getStatesOfCountry(countryCode).map((state) => ({
|
|
13697
|
+
...state,
|
|
13698
|
+
countryName
|
|
13699
|
+
}));
|
|
13700
|
+
}
|
|
13701
|
+
function getStateByCode(stateCode, countryCode) {
|
|
13702
|
+
const state = import_country_state_city3.State.getStateByCodeAndCountry(stateCode, countryCode);
|
|
13703
|
+
if (!state) return void 0;
|
|
13704
|
+
const countryName = import_country_state_city3.Country.getCountryByCode(countryCode)?.name ?? "";
|
|
13705
|
+
return { ...state, countryName };
|
|
13706
|
+
}
|
|
13707
|
+
function getStateByName(name, exact = false) {
|
|
13708
|
+
const q = name.toLowerCase();
|
|
13709
|
+
return getAllStatesCached().find(
|
|
13710
|
+
(s2) => exact ? s2.name.toLowerCase() === q : s2.name.toLowerCase().includes(q)
|
|
13711
|
+
);
|
|
13712
|
+
}
|
|
13713
|
+
function getStatesByName(name, exact = false) {
|
|
13714
|
+
const q = name.toLowerCase();
|
|
13715
|
+
return getAllStatesCached().filter(
|
|
13716
|
+
(s2) => exact ? s2.name.toLowerCase() === q : s2.name.toLowerCase().includes(q)
|
|
13717
|
+
);
|
|
13718
|
+
}
|
|
13719
|
+
function getCitiesOfState(countryCode, stateCode) {
|
|
13720
|
+
const countryName = import_country_state_city3.Country.getCountryByCode(countryCode)?.name ?? "";
|
|
13721
|
+
const stateName = import_country_state_city3.State.getStateByCodeAndCountry(stateCode, countryCode)?.name ?? "";
|
|
13722
|
+
return import_country_state_city3.City.getCitiesOfState(countryCode, stateCode).map((city) => ({
|
|
13723
|
+
...city,
|
|
13724
|
+
cityCode: city.name.slice(0, 3),
|
|
13725
|
+
countryName,
|
|
13726
|
+
stateName
|
|
13727
|
+
}));
|
|
13728
|
+
}
|
|
13729
|
+
function getCitiesOfCountry(countryCode) {
|
|
13730
|
+
const countryName = import_country_state_city3.Country.getCountryByCode(countryCode)?.name ?? "";
|
|
13731
|
+
const stateNameMap = getStateNameMap(countryCode);
|
|
13732
|
+
return (import_country_state_city3.City.getCitiesOfCountry(countryCode) ?? []).map((city) => ({
|
|
13733
|
+
...city,
|
|
13734
|
+
cityCode: city.name.slice(0, 3),
|
|
13735
|
+
countryName,
|
|
13736
|
+
stateName: stateNameMap.get(city.stateCode) ?? ""
|
|
13737
|
+
}));
|
|
13738
|
+
}
|
|
13739
|
+
function getCityByName(name, exact = false) {
|
|
13740
|
+
const q = name.toLowerCase();
|
|
13741
|
+
return getAllCitiesCached().find(
|
|
13742
|
+
(c) => exact ? c.name.toLowerCase() === q : c.name.toLowerCase().includes(q)
|
|
13743
|
+
);
|
|
13744
|
+
}
|
|
13745
|
+
function getCitiesByName(name, exact = false) {
|
|
13746
|
+
const q = name.toLowerCase();
|
|
13747
|
+
return getAllCitiesCached().filter(
|
|
13748
|
+
(c) => exact ? c.name.toLowerCase() === q : c.name.toLowerCase().includes(q)
|
|
13749
|
+
);
|
|
13750
|
+
}
|
|
13751
|
+
|
|
13752
|
+
// lib/utils/useLocationSearch.ts
|
|
13753
|
+
var import_react64 = require("react");
|
|
13754
|
+
function useDebounced(searcher, debounceMs) {
|
|
13755
|
+
const [query, setQuery] = (0, import_react64.useState)("");
|
|
13756
|
+
const [results, setResults] = (0, import_react64.useState)([]);
|
|
13757
|
+
const timer = (0, import_react64.useRef)(null);
|
|
13758
|
+
(0, import_react64.useEffect)(() => () => {
|
|
13759
|
+
if (timer.current) clearTimeout(timer.current);
|
|
13760
|
+
}, []);
|
|
13761
|
+
const search = (0, import_react64.useCallback)((name) => {
|
|
13762
|
+
setQuery(name);
|
|
13763
|
+
if (timer.current) clearTimeout(timer.current);
|
|
13764
|
+
if (!name.trim()) {
|
|
13765
|
+
setResults([]);
|
|
13766
|
+
return;
|
|
13767
|
+
}
|
|
13768
|
+
timer.current = setTimeout(() => {
|
|
13769
|
+
setResults(searcher(name));
|
|
13770
|
+
}, debounceMs);
|
|
13771
|
+
}, [searcher, debounceMs]);
|
|
13772
|
+
const clear = (0, import_react64.useCallback)(() => {
|
|
13773
|
+
if (timer.current) clearTimeout(timer.current);
|
|
13774
|
+
setQuery("");
|
|
13775
|
+
setResults([]);
|
|
13776
|
+
}, []);
|
|
13777
|
+
return { results, query, search, clear };
|
|
13778
|
+
}
|
|
13779
|
+
function useCountriesSearch(debounceMs = 300) {
|
|
13780
|
+
const searcher = (0, import_react64.useCallback)(
|
|
13781
|
+
(q) => getCountriesByName(q),
|
|
13782
|
+
[]
|
|
13783
|
+
);
|
|
13784
|
+
return useDebounced(searcher, debounceMs);
|
|
13785
|
+
}
|
|
13786
|
+
function useStatesSearch(debounceMs = 300) {
|
|
13787
|
+
const searcher = (0, import_react64.useCallback)(
|
|
13788
|
+
(q) => getStatesByName(q),
|
|
13789
|
+
[]
|
|
13790
|
+
);
|
|
13791
|
+
return useDebounced(searcher, debounceMs);
|
|
13792
|
+
}
|
|
13793
|
+
function useCitiesSearch(debounceMs = 300) {
|
|
13794
|
+
const searcher = (0, import_react64.useCallback)(
|
|
13795
|
+
(q) => getCitiesByName(q),
|
|
13796
|
+
[]
|
|
13797
|
+
);
|
|
13798
|
+
return useDebounced(searcher, debounceMs);
|
|
13799
|
+
}
|
|
13619
13800
|
// Annotate the CommonJS export names for ESM import in node:
|
|
13620
13801
|
0 && (module.exports = {
|
|
13621
13802
|
APP_THEMES,
|
|
@@ -13757,6 +13938,21 @@ var RufousTextContent = ({ content, className, style, sx }) => {
|
|
|
13757
13938
|
ViewIcon,
|
|
13758
13939
|
WorkItemIcon,
|
|
13759
13940
|
Zoom,
|
|
13941
|
+
getAllCountries,
|
|
13942
|
+
getCitiesByName,
|
|
13943
|
+
getCitiesOfCountry,
|
|
13944
|
+
getCitiesOfState,
|
|
13945
|
+
getCityByName,
|
|
13946
|
+
getCountriesByName,
|
|
13947
|
+
getCountryByCode,
|
|
13948
|
+
getCountryByName,
|
|
13949
|
+
getStateByCode,
|
|
13950
|
+
getStateByName,
|
|
13951
|
+
getStatesByName,
|
|
13952
|
+
getStatesOfCountry,
|
|
13760
13953
|
transformLegacyTodos,
|
|
13761
|
-
|
|
13954
|
+
useCitiesSearch,
|
|
13955
|
+
useCountriesSearch,
|
|
13956
|
+
useRufousTheme,
|
|
13957
|
+
useStatesSearch
|
|
13762
13958
|
});
|
package/dist/main.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { ReactNode, CSSProperties, InputHTMLAttributes, TextareaHTMLAttributes, ReactElement, ComponentType } from 'react';
|
|
3
|
+
import { ICity, ICountry, IState } from 'country-state-city';
|
|
3
4
|
|
|
4
5
|
declare const APP_THEMES: {
|
|
5
6
|
default: {
|
|
@@ -2058,4 +2059,132 @@ interface MentionItemData {
|
|
|
2058
2059
|
shortName?: string;
|
|
2059
2060
|
}
|
|
2060
2061
|
|
|
2061
|
-
|
|
2062
|
+
/** Country — same shape as the library; re-exported with a typed name for convenience. */
|
|
2063
|
+
type EnhancedCountry = ICountry;
|
|
2064
|
+
/** State enriched with the full name of its parent country. */
|
|
2065
|
+
interface EnhancedState extends IState {
|
|
2066
|
+
countryName: string;
|
|
2067
|
+
}
|
|
2068
|
+
/** City enriched with a short city code and the full state + country names. */
|
|
2069
|
+
interface EnhancedCity extends ICity {
|
|
2070
|
+
/** First three characters of the city name (e.g. "Des" for "Des Moines"). */
|
|
2071
|
+
cityCode: string;
|
|
2072
|
+
/** Full name of the parent country (e.g. "United States"). */
|
|
2073
|
+
countryName: string;
|
|
2074
|
+
/** Full name of the parent state (e.g. "Iowa"). */
|
|
2075
|
+
stateName: string;
|
|
2076
|
+
}
|
|
2077
|
+
/** Returns all countries (same data as the library, typed as EnhancedCountry). */
|
|
2078
|
+
declare function getAllCountries(): EnhancedCountry[];
|
|
2079
|
+
/** Returns a single country by its ISO 2-letter code, or undefined if not found. */
|
|
2080
|
+
declare function getCountryByCode(isoCode: string): EnhancedCountry | undefined;
|
|
2081
|
+
/**
|
|
2082
|
+
* Returns the first country whose name matches the query (case-insensitive).
|
|
2083
|
+
* Pass `exact: false` (default) to also match partial names.
|
|
2084
|
+
* @param name Country name or partial name, e.g. "United States" or "united"
|
|
2085
|
+
* @param exact When true, requires an exact case-insensitive match. Default false.
|
|
2086
|
+
*/
|
|
2087
|
+
declare function getCountryByName(name: string, exact?: boolean): EnhancedCountry | undefined;
|
|
2088
|
+
/**
|
|
2089
|
+
* Returns all countries whose names match the query (case-insensitive, partial by default).
|
|
2090
|
+
* Useful for search-as-you-type flows where you want multiple candidates.
|
|
2091
|
+
* @param name Search string, e.g. "ind" matches "India", "Indonesia", etc.
|
|
2092
|
+
* @param exact When true, only exact case-insensitive matches are returned. Default false.
|
|
2093
|
+
*/
|
|
2094
|
+
declare function getCountriesByName(name: string, exact?: boolean): EnhancedCountry[];
|
|
2095
|
+
/**
|
|
2096
|
+
* Returns all states for a country, each enriched with `countryName`.
|
|
2097
|
+
* @param countryCode ISO 2-letter country code, e.g. "US"
|
|
2098
|
+
*/
|
|
2099
|
+
declare function getStatesOfCountry(countryCode: string): EnhancedState[];
|
|
2100
|
+
/**
|
|
2101
|
+
* Returns a single state by its code + parent country, enriched with `countryName`.
|
|
2102
|
+
* @param stateCode ISO state code, e.g. "IA"
|
|
2103
|
+
* @param countryCode ISO 2-letter country code, e.g. "US"
|
|
2104
|
+
*/
|
|
2105
|
+
declare function getStateByCode(stateCode: string, countryCode: string): EnhancedState | undefined;
|
|
2106
|
+
/**
|
|
2107
|
+
* Returns the first state whose name matches the query across **all countries** (case-insensitive).
|
|
2108
|
+
* @param name State name or partial name, e.g. "Iowa" or "iow"
|
|
2109
|
+
* @param exact When true, requires an exact case-insensitive match. Default false.
|
|
2110
|
+
*/
|
|
2111
|
+
declare function getStateByName(name: string, exact?: boolean): EnhancedState | undefined;
|
|
2112
|
+
/**
|
|
2113
|
+
* Returns all states whose names match the query across **all countries** (case-insensitive, partial by default).
|
|
2114
|
+
* @param name Search string, e.g. "new" matches "New York", "New South Wales", etc.
|
|
2115
|
+
* @param exact When true, only exact case-insensitive matches are returned. Default false.
|
|
2116
|
+
*/
|
|
2117
|
+
declare function getStatesByName(name: string, exact?: boolean): EnhancedState[];
|
|
2118
|
+
/**
|
|
2119
|
+
* Returns all cities for a given state, each enriched with `cityCode`, `countryName`,
|
|
2120
|
+
* and `stateName`.
|
|
2121
|
+
* @param countryCode ISO 2-letter country code, e.g. "US"
|
|
2122
|
+
* @param stateCode ISO state code, e.g. "IA"
|
|
2123
|
+
*/
|
|
2124
|
+
declare function getCitiesOfState(countryCode: string, stateCode: string): EnhancedCity[];
|
|
2125
|
+
/**
|
|
2126
|
+
* Returns all cities for a given country, each enriched with `cityCode`, `countryName`,
|
|
2127
|
+
* and `stateName`.
|
|
2128
|
+
* @param countryCode ISO 2-letter country code, e.g. "US"
|
|
2129
|
+
*/
|
|
2130
|
+
declare function getCitiesOfCountry(countryCode: string): EnhancedCity[];
|
|
2131
|
+
/**
|
|
2132
|
+
* Returns the first city whose name matches the query across **all countries and states** (case-insensitive).
|
|
2133
|
+
* @param name City name or partial name, e.g. "Delhi" or "del"
|
|
2134
|
+
* @param exact When true, requires an exact case-insensitive match. Default false.
|
|
2135
|
+
*/
|
|
2136
|
+
declare function getCityByName(name: string, exact?: boolean): EnhancedCity | undefined;
|
|
2137
|
+
/**
|
|
2138
|
+
* Returns all cities whose names match the query across **all countries and states** (case-insensitive, partial by default).
|
|
2139
|
+
* Searches ~148k cities — prefer the debounced `useCitiesSearch` hook in React components.
|
|
2140
|
+
* @param name Search string, e.g. "spring" matches "Springfield", "Spring Hill", etc.
|
|
2141
|
+
* @param exact When true, only exact case-insensitive matches are returned. Default false.
|
|
2142
|
+
*/
|
|
2143
|
+
declare function getCitiesByName(name: string, exact?: boolean): EnhancedCity[];
|
|
2144
|
+
|
|
2145
|
+
interface SearchResult<T> {
|
|
2146
|
+
/** Filtered results. Empty while query is blank. */
|
|
2147
|
+
results: T[];
|
|
2148
|
+
/** Current value of the search input (updated immediately on each keystroke). */
|
|
2149
|
+
query: string;
|
|
2150
|
+
/** Call this on every keystroke — triggers the debounced filter. */
|
|
2151
|
+
search: (name: string) => void;
|
|
2152
|
+
/** Resets query and results immediately. */
|
|
2153
|
+
clear: () => void;
|
|
2154
|
+
}
|
|
2155
|
+
/**
|
|
2156
|
+
* Debounced country name search across all ~250 countries.
|
|
2157
|
+
*
|
|
2158
|
+
* @param debounceMs Delay before filtering runs. Defaults to 300 ms.
|
|
2159
|
+
*
|
|
2160
|
+
* @example
|
|
2161
|
+
* const { results, search, clear, query } = useCountriesSearch();
|
|
2162
|
+
* <input onChange={e => search(e.target.value)} value={query} />
|
|
2163
|
+
* {results.map(c => <div key={c.isoCode}>{c.flag} {c.name}</div>)}
|
|
2164
|
+
*/
|
|
2165
|
+
declare function useCountriesSearch(debounceMs?: number): SearchResult<EnhancedCountry>;
|
|
2166
|
+
/**
|
|
2167
|
+
* Debounced state / province name search across **all countries** (~5k states).
|
|
2168
|
+
* No country scoping — results include `countryName` so you can display origin.
|
|
2169
|
+
*
|
|
2170
|
+
* @param debounceMs Delay before filtering runs. Defaults to 300 ms.
|
|
2171
|
+
*
|
|
2172
|
+
* @example
|
|
2173
|
+
* const { results, search, clear } = useStatesSearch();
|
|
2174
|
+
* // results[0] → { name, isoCode, countryCode, countryName, latitude, longitude }
|
|
2175
|
+
*/
|
|
2176
|
+
declare function useStatesSearch(debounceMs?: number): SearchResult<EnhancedState>;
|
|
2177
|
+
/**
|
|
2178
|
+
* Debounced city name search across **all countries and states** (~148k cities).
|
|
2179
|
+
* No country / state scoping — results include `countryName` and `stateName`.
|
|
2180
|
+
* Debouncing is strongly recommended given the dataset size.
|
|
2181
|
+
*
|
|
2182
|
+
* @param debounceMs Delay before filtering runs. Defaults to 300 ms.
|
|
2183
|
+
*
|
|
2184
|
+
* @example
|
|
2185
|
+
* const { results, search, clear } = useCitiesSearch(400);
|
|
2186
|
+
* // results[0] → { name, cityCode, stateCode, stateName, countryCode, countryName, … }
|
|
2187
|
+
*/
|
|
2188
|
+
declare function useCitiesSearch(debounceMs?: number): SearchResult<EnhancedCity>;
|
|
2189
|
+
|
|
2190
|
+
export { APP_THEMES, Accordion, AccordionDetails, type AccordionDetailsProps, type AccordionProps, AccordionSummary, type AccordionSummaryProps, type Action, ActivateUserIcon, AddButton, AddressLookup, ArchivedIcon, AssignGroupIcon, Autocomplete, type AutocompleteProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, BaseDialog, Box, type BoxProps, Breadcrumbs, type BreadcrumbsProps, Button, type ButtonProps, CameraIcon, CancelButton, Card, CardActions, type CardActionsProps, CardContent, type CardContentProps, CardHeader, type CardHeaderProps, CardMedia, type CardMediaProps, type CardProps, Checkbox, type CheckboxProps, Chip, type ChipProps, CircularProgress, CircularProgressIcon, type CircularProgressIconProps, CloseIcon, Collapse, type CollapseProps, type Column, CopyIcon, DataGrid, type DataGridProps, DateField, type DateFieldProps, type DateFormatString, DateRangeField, type DateRangeFieldProps, type DateRangeValue, DifficultyAllIcon, DifficultyEasyIcon, DifficultyHardIcon, DifficultyMediumIcon, Divider, type DividerProps, DollarIcon, DownloadIcon, DownloadPdfIcon, Drawer, type DrawerProps, EditChatIcon, EditIcon, EngagementIcon, type EnhancedCity, type EnhancedCountry, type EnhancedState, Fade, type FadeProps, FunctionIcon, Grid, type GridProps, Grow, type GrowProps, HelpOutlinedIcon, HierarchyIcon, IconButton, type IconButtonProps, ImageField, type ImageFieldProps, InactiveGroupIcon, IndustryIcon, InvoiceIcon, Link, type LinkProps, List, ListItem, ListItemButton, type ListItemButtonProps, ListItemIcon, type ListItemIconProps, type ListItemProps, ListItemText, type ListItemTextProps, type ListProps, ListSubheader, type ListSubheaderProps, LocationPinIcon, LogsIcon, Menu, MenuDivider, MenuItem, type MenuItemProps, MenuList, type MenuListProps, type MenuProps, MinExperienceIcon, NineDotMenuIcon, NotificationIcon, type NumberVariant, Paper, type PaperProps, PhoneField, type PhoneFieldProps, Popover, type PopoverProps, Popper, type PopperProps, ProjectIcon, QualificationsIcon, QuestionStatusAllIcon, QuestionStatusPrivateIcon, QuestionStatusPublicIcon, QuestionTypeAllIcon, QuestionTypeCodingIcon, QuestionTypeDescriptiveIcon, QuestionTypeMultipleIcon, QuestionTypeSingleIcon, Radio, RadioGroup, type RadioGroupProps, type RadioProps, Rating, type RatingProps, RefreshIcon, ResendInviteIcon, RolesIcon, RufousAiIcon, RufousBirdIcon, RufousLauncherIcon, RufousLogoLoader, type RufousLogoLoaderProps, RufousTextContent, type RufousTextContentProps, RufousTextEditor, type MentionItemData as RufousTextEditorMentionItem, type RufousTextEditorProps, RufousThemeProvider, Select, type SelectProps, SidebarIcon, Skeleton, type SkeletonProps, Slide, type SlideProps, Slider, type SliderProps, SmartSelect, type SmartSelectProps, Snackbar, type SnackbarProps, SoftSkillsIcon, type SortDirection, Stack, type StackProps, StandardButton, Step, StepButton, type StepButtonProps, StepContent, type StepContentProps, StepLabel, type StepLabelProps, type StepProps, Stepper, type StepperProps, SubmitButton, SubscribeIcon, SuspendUserIcon, Switch, type SwitchProps, type SxProp, Tab, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps, TechnicalSkillsIcon, TextField, type TextFieldProps, TickIcon, TimerIcon, ToggleButton, ToggleButtonGroup, type ToggleButtonGroupProps, type ToggleButtonProps, Tooltip, type TooltipProps, TrashIcon, type TreeNode, TreeSelect, type TreeSelectMultiValue, type TreeSelectProps, type TreeSelectValue, Typography, type TypographyProps, UnArchivedIcon, UnsubscribeIcon, UploadIcon, UserAssignIcon, type UserOption, UserSelectionField, type UserSelectionFieldProps, ViewIcon, WorkItemIcon, Zoom, type ZoomProps, getAllCountries, getCitiesByName, getCitiesOfCountry, getCitiesOfState, getCityByName, getCountriesByName, getCountryByCode, getCountryByName, getStateByCode, getStateByName, getStatesByName, getStatesOfCountry, transformLegacyTodos, useCitiesSearch, useCountriesSearch, useRufousTheme, useStatesSearch };
|
package/dist/main.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { ReactNode, CSSProperties, InputHTMLAttributes, TextareaHTMLAttributes, ReactElement, ComponentType } from 'react';
|
|
3
|
+
import { ICity, ICountry, IState } from 'country-state-city';
|
|
3
4
|
|
|
4
5
|
declare const APP_THEMES: {
|
|
5
6
|
default: {
|
|
@@ -2058,4 +2059,132 @@ interface MentionItemData {
|
|
|
2058
2059
|
shortName?: string;
|
|
2059
2060
|
}
|
|
2060
2061
|
|
|
2061
|
-
|
|
2062
|
+
/** Country — same shape as the library; re-exported with a typed name for convenience. */
|
|
2063
|
+
type EnhancedCountry = ICountry;
|
|
2064
|
+
/** State enriched with the full name of its parent country. */
|
|
2065
|
+
interface EnhancedState extends IState {
|
|
2066
|
+
countryName: string;
|
|
2067
|
+
}
|
|
2068
|
+
/** City enriched with a short city code and the full state + country names. */
|
|
2069
|
+
interface EnhancedCity extends ICity {
|
|
2070
|
+
/** First three characters of the city name (e.g. "Des" for "Des Moines"). */
|
|
2071
|
+
cityCode: string;
|
|
2072
|
+
/** Full name of the parent country (e.g. "United States"). */
|
|
2073
|
+
countryName: string;
|
|
2074
|
+
/** Full name of the parent state (e.g. "Iowa"). */
|
|
2075
|
+
stateName: string;
|
|
2076
|
+
}
|
|
2077
|
+
/** Returns all countries (same data as the library, typed as EnhancedCountry). */
|
|
2078
|
+
declare function getAllCountries(): EnhancedCountry[];
|
|
2079
|
+
/** Returns a single country by its ISO 2-letter code, or undefined if not found. */
|
|
2080
|
+
declare function getCountryByCode(isoCode: string): EnhancedCountry | undefined;
|
|
2081
|
+
/**
|
|
2082
|
+
* Returns the first country whose name matches the query (case-insensitive).
|
|
2083
|
+
* Pass `exact: false` (default) to also match partial names.
|
|
2084
|
+
* @param name Country name or partial name, e.g. "United States" or "united"
|
|
2085
|
+
* @param exact When true, requires an exact case-insensitive match. Default false.
|
|
2086
|
+
*/
|
|
2087
|
+
declare function getCountryByName(name: string, exact?: boolean): EnhancedCountry | undefined;
|
|
2088
|
+
/**
|
|
2089
|
+
* Returns all countries whose names match the query (case-insensitive, partial by default).
|
|
2090
|
+
* Useful for search-as-you-type flows where you want multiple candidates.
|
|
2091
|
+
* @param name Search string, e.g. "ind" matches "India", "Indonesia", etc.
|
|
2092
|
+
* @param exact When true, only exact case-insensitive matches are returned. Default false.
|
|
2093
|
+
*/
|
|
2094
|
+
declare function getCountriesByName(name: string, exact?: boolean): EnhancedCountry[];
|
|
2095
|
+
/**
|
|
2096
|
+
* Returns all states for a country, each enriched with `countryName`.
|
|
2097
|
+
* @param countryCode ISO 2-letter country code, e.g. "US"
|
|
2098
|
+
*/
|
|
2099
|
+
declare function getStatesOfCountry(countryCode: string): EnhancedState[];
|
|
2100
|
+
/**
|
|
2101
|
+
* Returns a single state by its code + parent country, enriched with `countryName`.
|
|
2102
|
+
* @param stateCode ISO state code, e.g. "IA"
|
|
2103
|
+
* @param countryCode ISO 2-letter country code, e.g. "US"
|
|
2104
|
+
*/
|
|
2105
|
+
declare function getStateByCode(stateCode: string, countryCode: string): EnhancedState | undefined;
|
|
2106
|
+
/**
|
|
2107
|
+
* Returns the first state whose name matches the query across **all countries** (case-insensitive).
|
|
2108
|
+
* @param name State name or partial name, e.g. "Iowa" or "iow"
|
|
2109
|
+
* @param exact When true, requires an exact case-insensitive match. Default false.
|
|
2110
|
+
*/
|
|
2111
|
+
declare function getStateByName(name: string, exact?: boolean): EnhancedState | undefined;
|
|
2112
|
+
/**
|
|
2113
|
+
* Returns all states whose names match the query across **all countries** (case-insensitive, partial by default).
|
|
2114
|
+
* @param name Search string, e.g. "new" matches "New York", "New South Wales", etc.
|
|
2115
|
+
* @param exact When true, only exact case-insensitive matches are returned. Default false.
|
|
2116
|
+
*/
|
|
2117
|
+
declare function getStatesByName(name: string, exact?: boolean): EnhancedState[];
|
|
2118
|
+
/**
|
|
2119
|
+
* Returns all cities for a given state, each enriched with `cityCode`, `countryName`,
|
|
2120
|
+
* and `stateName`.
|
|
2121
|
+
* @param countryCode ISO 2-letter country code, e.g. "US"
|
|
2122
|
+
* @param stateCode ISO state code, e.g. "IA"
|
|
2123
|
+
*/
|
|
2124
|
+
declare function getCitiesOfState(countryCode: string, stateCode: string): EnhancedCity[];
|
|
2125
|
+
/**
|
|
2126
|
+
* Returns all cities for a given country, each enriched with `cityCode`, `countryName`,
|
|
2127
|
+
* and `stateName`.
|
|
2128
|
+
* @param countryCode ISO 2-letter country code, e.g. "US"
|
|
2129
|
+
*/
|
|
2130
|
+
declare function getCitiesOfCountry(countryCode: string): EnhancedCity[];
|
|
2131
|
+
/**
|
|
2132
|
+
* Returns the first city whose name matches the query across **all countries and states** (case-insensitive).
|
|
2133
|
+
* @param name City name or partial name, e.g. "Delhi" or "del"
|
|
2134
|
+
* @param exact When true, requires an exact case-insensitive match. Default false.
|
|
2135
|
+
*/
|
|
2136
|
+
declare function getCityByName(name: string, exact?: boolean): EnhancedCity | undefined;
|
|
2137
|
+
/**
|
|
2138
|
+
* Returns all cities whose names match the query across **all countries and states** (case-insensitive, partial by default).
|
|
2139
|
+
* Searches ~148k cities — prefer the debounced `useCitiesSearch` hook in React components.
|
|
2140
|
+
* @param name Search string, e.g. "spring" matches "Springfield", "Spring Hill", etc.
|
|
2141
|
+
* @param exact When true, only exact case-insensitive matches are returned. Default false.
|
|
2142
|
+
*/
|
|
2143
|
+
declare function getCitiesByName(name: string, exact?: boolean): EnhancedCity[];
|
|
2144
|
+
|
|
2145
|
+
interface SearchResult<T> {
|
|
2146
|
+
/** Filtered results. Empty while query is blank. */
|
|
2147
|
+
results: T[];
|
|
2148
|
+
/** Current value of the search input (updated immediately on each keystroke). */
|
|
2149
|
+
query: string;
|
|
2150
|
+
/** Call this on every keystroke — triggers the debounced filter. */
|
|
2151
|
+
search: (name: string) => void;
|
|
2152
|
+
/** Resets query and results immediately. */
|
|
2153
|
+
clear: () => void;
|
|
2154
|
+
}
|
|
2155
|
+
/**
|
|
2156
|
+
* Debounced country name search across all ~250 countries.
|
|
2157
|
+
*
|
|
2158
|
+
* @param debounceMs Delay before filtering runs. Defaults to 300 ms.
|
|
2159
|
+
*
|
|
2160
|
+
* @example
|
|
2161
|
+
* const { results, search, clear, query } = useCountriesSearch();
|
|
2162
|
+
* <input onChange={e => search(e.target.value)} value={query} />
|
|
2163
|
+
* {results.map(c => <div key={c.isoCode}>{c.flag} {c.name}</div>)}
|
|
2164
|
+
*/
|
|
2165
|
+
declare function useCountriesSearch(debounceMs?: number): SearchResult<EnhancedCountry>;
|
|
2166
|
+
/**
|
|
2167
|
+
* Debounced state / province name search across **all countries** (~5k states).
|
|
2168
|
+
* No country scoping — results include `countryName` so you can display origin.
|
|
2169
|
+
*
|
|
2170
|
+
* @param debounceMs Delay before filtering runs. Defaults to 300 ms.
|
|
2171
|
+
*
|
|
2172
|
+
* @example
|
|
2173
|
+
* const { results, search, clear } = useStatesSearch();
|
|
2174
|
+
* // results[0] → { name, isoCode, countryCode, countryName, latitude, longitude }
|
|
2175
|
+
*/
|
|
2176
|
+
declare function useStatesSearch(debounceMs?: number): SearchResult<EnhancedState>;
|
|
2177
|
+
/**
|
|
2178
|
+
* Debounced city name search across **all countries and states** (~148k cities).
|
|
2179
|
+
* No country / state scoping — results include `countryName` and `stateName`.
|
|
2180
|
+
* Debouncing is strongly recommended given the dataset size.
|
|
2181
|
+
*
|
|
2182
|
+
* @param debounceMs Delay before filtering runs. Defaults to 300 ms.
|
|
2183
|
+
*
|
|
2184
|
+
* @example
|
|
2185
|
+
* const { results, search, clear } = useCitiesSearch(400);
|
|
2186
|
+
* // results[0] → { name, cityCode, stateCode, stateName, countryCode, countryName, … }
|
|
2187
|
+
*/
|
|
2188
|
+
declare function useCitiesSearch(debounceMs?: number): SearchResult<EnhancedCity>;
|
|
2189
|
+
|
|
2190
|
+
export { APP_THEMES, Accordion, AccordionDetails, type AccordionDetailsProps, type AccordionProps, AccordionSummary, type AccordionSummaryProps, type Action, ActivateUserIcon, AddButton, AddressLookup, ArchivedIcon, AssignGroupIcon, Autocomplete, type AutocompleteProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, BaseDialog, Box, type BoxProps, Breadcrumbs, type BreadcrumbsProps, Button, type ButtonProps, CameraIcon, CancelButton, Card, CardActions, type CardActionsProps, CardContent, type CardContentProps, CardHeader, type CardHeaderProps, CardMedia, type CardMediaProps, type CardProps, Checkbox, type CheckboxProps, Chip, type ChipProps, CircularProgress, CircularProgressIcon, type CircularProgressIconProps, CloseIcon, Collapse, type CollapseProps, type Column, CopyIcon, DataGrid, type DataGridProps, DateField, type DateFieldProps, type DateFormatString, DateRangeField, type DateRangeFieldProps, type DateRangeValue, DifficultyAllIcon, DifficultyEasyIcon, DifficultyHardIcon, DifficultyMediumIcon, Divider, type DividerProps, DollarIcon, DownloadIcon, DownloadPdfIcon, Drawer, type DrawerProps, EditChatIcon, EditIcon, EngagementIcon, type EnhancedCity, type EnhancedCountry, type EnhancedState, Fade, type FadeProps, FunctionIcon, Grid, type GridProps, Grow, type GrowProps, HelpOutlinedIcon, HierarchyIcon, IconButton, type IconButtonProps, ImageField, type ImageFieldProps, InactiveGroupIcon, IndustryIcon, InvoiceIcon, Link, type LinkProps, List, ListItem, ListItemButton, type ListItemButtonProps, ListItemIcon, type ListItemIconProps, type ListItemProps, ListItemText, type ListItemTextProps, type ListProps, ListSubheader, type ListSubheaderProps, LocationPinIcon, LogsIcon, Menu, MenuDivider, MenuItem, type MenuItemProps, MenuList, type MenuListProps, type MenuProps, MinExperienceIcon, NineDotMenuIcon, NotificationIcon, type NumberVariant, Paper, type PaperProps, PhoneField, type PhoneFieldProps, Popover, type PopoverProps, Popper, type PopperProps, ProjectIcon, QualificationsIcon, QuestionStatusAllIcon, QuestionStatusPrivateIcon, QuestionStatusPublicIcon, QuestionTypeAllIcon, QuestionTypeCodingIcon, QuestionTypeDescriptiveIcon, QuestionTypeMultipleIcon, QuestionTypeSingleIcon, Radio, RadioGroup, type RadioGroupProps, type RadioProps, Rating, type RatingProps, RefreshIcon, ResendInviteIcon, RolesIcon, RufousAiIcon, RufousBirdIcon, RufousLauncherIcon, RufousLogoLoader, type RufousLogoLoaderProps, RufousTextContent, type RufousTextContentProps, RufousTextEditor, type MentionItemData as RufousTextEditorMentionItem, type RufousTextEditorProps, RufousThemeProvider, Select, type SelectProps, SidebarIcon, Skeleton, type SkeletonProps, Slide, type SlideProps, Slider, type SliderProps, SmartSelect, type SmartSelectProps, Snackbar, type SnackbarProps, SoftSkillsIcon, type SortDirection, Stack, type StackProps, StandardButton, Step, StepButton, type StepButtonProps, StepContent, type StepContentProps, StepLabel, type StepLabelProps, type StepProps, Stepper, type StepperProps, SubmitButton, SubscribeIcon, SuspendUserIcon, Switch, type SwitchProps, type SxProp, Tab, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps, TechnicalSkillsIcon, TextField, type TextFieldProps, TickIcon, TimerIcon, ToggleButton, ToggleButtonGroup, type ToggleButtonGroupProps, type ToggleButtonProps, Tooltip, type TooltipProps, TrashIcon, type TreeNode, TreeSelect, type TreeSelectMultiValue, type TreeSelectProps, type TreeSelectValue, Typography, type TypographyProps, UnArchivedIcon, UnsubscribeIcon, UploadIcon, UserAssignIcon, type UserOption, UserSelectionField, type UserSelectionFieldProps, ViewIcon, WorkItemIcon, Zoom, type ZoomProps, getAllCountries, getCitiesByName, getCitiesOfCountry, getCitiesOfState, getCityByName, getCountriesByName, getCountryByCode, getCountryByName, getStateByCode, getStateByName, getStatesByName, getStatesOfCountry, transformLegacyTodos, useCitiesSearch, useCountriesSearch, useRufousTheme, useStatesSearch };
|
package/dist/main.js
CHANGED
|
@@ -13555,6 +13555,172 @@ var RufousTextContent = ({ content, className, style, sx }) => {
|
|
|
13555
13555
|
}
|
|
13556
13556
|
);
|
|
13557
13557
|
};
|
|
13558
|
+
|
|
13559
|
+
// lib/utils/locationData.ts
|
|
13560
|
+
import { Country as Country3, State as State2, City as City2 } from "country-state-city";
|
|
13561
|
+
var _stateNameCache = /* @__PURE__ */ new Map();
|
|
13562
|
+
function getStateNameMap(countryCode) {
|
|
13563
|
+
if (!_stateNameCache.has(countryCode)) {
|
|
13564
|
+
const map = /* @__PURE__ */ new Map();
|
|
13565
|
+
State2.getStatesOfCountry(countryCode).forEach((s2) => map.set(s2.isoCode, s2.name));
|
|
13566
|
+
_stateNameCache.set(countryCode, map);
|
|
13567
|
+
}
|
|
13568
|
+
return _stateNameCache.get(countryCode);
|
|
13569
|
+
}
|
|
13570
|
+
var _allCountriesCache = null;
|
|
13571
|
+
function getAllCountriesCached() {
|
|
13572
|
+
if (!_allCountriesCache) _allCountriesCache = Country3.getAllCountries();
|
|
13573
|
+
return _allCountriesCache;
|
|
13574
|
+
}
|
|
13575
|
+
var _allStatesCache = null;
|
|
13576
|
+
function getAllStatesCached() {
|
|
13577
|
+
if (!_allStatesCache) {
|
|
13578
|
+
const countryMap = new Map(Country3.getAllCountries().map((c) => [c.isoCode, c.name]));
|
|
13579
|
+
_allStatesCache = State2.getAllStates().map((s2) => ({
|
|
13580
|
+
...s2,
|
|
13581
|
+
countryName: countryMap.get(s2.countryCode) ?? ""
|
|
13582
|
+
}));
|
|
13583
|
+
}
|
|
13584
|
+
return _allStatesCache;
|
|
13585
|
+
}
|
|
13586
|
+
var _allCitiesCache = null;
|
|
13587
|
+
function getAllCitiesCached() {
|
|
13588
|
+
if (!_allCitiesCache) {
|
|
13589
|
+
const countryMap = new Map(Country3.getAllCountries().map((c) => [c.isoCode, c.name]));
|
|
13590
|
+
const stateMap = new Map(State2.getAllStates().map((s2) => [`${s2.countryCode}:${s2.isoCode}`, s2.name]));
|
|
13591
|
+
_allCitiesCache = City2.getAllCities().map((city) => ({
|
|
13592
|
+
...city,
|
|
13593
|
+
cityCode: city.name.slice(0, 3),
|
|
13594
|
+
countryName: countryMap.get(city.countryCode) ?? "",
|
|
13595
|
+
stateName: stateMap.get(`${city.countryCode}:${city.stateCode}`) ?? ""
|
|
13596
|
+
}));
|
|
13597
|
+
}
|
|
13598
|
+
return _allCitiesCache;
|
|
13599
|
+
}
|
|
13600
|
+
function getAllCountries2() {
|
|
13601
|
+
return getAllCountriesCached();
|
|
13602
|
+
}
|
|
13603
|
+
function getCountryByCode(isoCode) {
|
|
13604
|
+
return Country3.getCountryByCode(isoCode) ?? void 0;
|
|
13605
|
+
}
|
|
13606
|
+
function getCountryByName(name, exact = false) {
|
|
13607
|
+
const q = name.toLowerCase();
|
|
13608
|
+
return getAllCountriesCached().find(
|
|
13609
|
+
(c) => exact ? c.name.toLowerCase() === q : c.name.toLowerCase().includes(q)
|
|
13610
|
+
);
|
|
13611
|
+
}
|
|
13612
|
+
function getCountriesByName(name, exact = false) {
|
|
13613
|
+
const q = name.toLowerCase();
|
|
13614
|
+
return getAllCountriesCached().filter(
|
|
13615
|
+
(c) => exact ? c.name.toLowerCase() === q : c.name.toLowerCase().includes(q)
|
|
13616
|
+
);
|
|
13617
|
+
}
|
|
13618
|
+
function getStatesOfCountry(countryCode) {
|
|
13619
|
+
const countryName = Country3.getCountryByCode(countryCode)?.name ?? "";
|
|
13620
|
+
return State2.getStatesOfCountry(countryCode).map((state) => ({
|
|
13621
|
+
...state,
|
|
13622
|
+
countryName
|
|
13623
|
+
}));
|
|
13624
|
+
}
|
|
13625
|
+
function getStateByCode(stateCode, countryCode) {
|
|
13626
|
+
const state = State2.getStateByCodeAndCountry(stateCode, countryCode);
|
|
13627
|
+
if (!state) return void 0;
|
|
13628
|
+
const countryName = Country3.getCountryByCode(countryCode)?.name ?? "";
|
|
13629
|
+
return { ...state, countryName };
|
|
13630
|
+
}
|
|
13631
|
+
function getStateByName(name, exact = false) {
|
|
13632
|
+
const q = name.toLowerCase();
|
|
13633
|
+
return getAllStatesCached().find(
|
|
13634
|
+
(s2) => exact ? s2.name.toLowerCase() === q : s2.name.toLowerCase().includes(q)
|
|
13635
|
+
);
|
|
13636
|
+
}
|
|
13637
|
+
function getStatesByName(name, exact = false) {
|
|
13638
|
+
const q = name.toLowerCase();
|
|
13639
|
+
return getAllStatesCached().filter(
|
|
13640
|
+
(s2) => exact ? s2.name.toLowerCase() === q : s2.name.toLowerCase().includes(q)
|
|
13641
|
+
);
|
|
13642
|
+
}
|
|
13643
|
+
function getCitiesOfState(countryCode, stateCode) {
|
|
13644
|
+
const countryName = Country3.getCountryByCode(countryCode)?.name ?? "";
|
|
13645
|
+
const stateName = State2.getStateByCodeAndCountry(stateCode, countryCode)?.name ?? "";
|
|
13646
|
+
return City2.getCitiesOfState(countryCode, stateCode).map((city) => ({
|
|
13647
|
+
...city,
|
|
13648
|
+
cityCode: city.name.slice(0, 3),
|
|
13649
|
+
countryName,
|
|
13650
|
+
stateName
|
|
13651
|
+
}));
|
|
13652
|
+
}
|
|
13653
|
+
function getCitiesOfCountry(countryCode) {
|
|
13654
|
+
const countryName = Country3.getCountryByCode(countryCode)?.name ?? "";
|
|
13655
|
+
const stateNameMap = getStateNameMap(countryCode);
|
|
13656
|
+
return (City2.getCitiesOfCountry(countryCode) ?? []).map((city) => ({
|
|
13657
|
+
...city,
|
|
13658
|
+
cityCode: city.name.slice(0, 3),
|
|
13659
|
+
countryName,
|
|
13660
|
+
stateName: stateNameMap.get(city.stateCode) ?? ""
|
|
13661
|
+
}));
|
|
13662
|
+
}
|
|
13663
|
+
function getCityByName(name, exact = false) {
|
|
13664
|
+
const q = name.toLowerCase();
|
|
13665
|
+
return getAllCitiesCached().find(
|
|
13666
|
+
(c) => exact ? c.name.toLowerCase() === q : c.name.toLowerCase().includes(q)
|
|
13667
|
+
);
|
|
13668
|
+
}
|
|
13669
|
+
function getCitiesByName(name, exact = false) {
|
|
13670
|
+
const q = name.toLowerCase();
|
|
13671
|
+
return getAllCitiesCached().filter(
|
|
13672
|
+
(c) => exact ? c.name.toLowerCase() === q : c.name.toLowerCase().includes(q)
|
|
13673
|
+
);
|
|
13674
|
+
}
|
|
13675
|
+
|
|
13676
|
+
// lib/utils/useLocationSearch.ts
|
|
13677
|
+
import { useState as useState36, useEffect as useEffect31, useRef as useRef34, useCallback as useCallback17 } from "react";
|
|
13678
|
+
function useDebounced(searcher, debounceMs) {
|
|
13679
|
+
const [query, setQuery] = useState36("");
|
|
13680
|
+
const [results, setResults] = useState36([]);
|
|
13681
|
+
const timer = useRef34(null);
|
|
13682
|
+
useEffect31(() => () => {
|
|
13683
|
+
if (timer.current) clearTimeout(timer.current);
|
|
13684
|
+
}, []);
|
|
13685
|
+
const search = useCallback17((name) => {
|
|
13686
|
+
setQuery(name);
|
|
13687
|
+
if (timer.current) clearTimeout(timer.current);
|
|
13688
|
+
if (!name.trim()) {
|
|
13689
|
+
setResults([]);
|
|
13690
|
+
return;
|
|
13691
|
+
}
|
|
13692
|
+
timer.current = setTimeout(() => {
|
|
13693
|
+
setResults(searcher(name));
|
|
13694
|
+
}, debounceMs);
|
|
13695
|
+
}, [searcher, debounceMs]);
|
|
13696
|
+
const clear = useCallback17(() => {
|
|
13697
|
+
if (timer.current) clearTimeout(timer.current);
|
|
13698
|
+
setQuery("");
|
|
13699
|
+
setResults([]);
|
|
13700
|
+
}, []);
|
|
13701
|
+
return { results, query, search, clear };
|
|
13702
|
+
}
|
|
13703
|
+
function useCountriesSearch(debounceMs = 300) {
|
|
13704
|
+
const searcher = useCallback17(
|
|
13705
|
+
(q) => getCountriesByName(q),
|
|
13706
|
+
[]
|
|
13707
|
+
);
|
|
13708
|
+
return useDebounced(searcher, debounceMs);
|
|
13709
|
+
}
|
|
13710
|
+
function useStatesSearch(debounceMs = 300) {
|
|
13711
|
+
const searcher = useCallback17(
|
|
13712
|
+
(q) => getStatesByName(q),
|
|
13713
|
+
[]
|
|
13714
|
+
);
|
|
13715
|
+
return useDebounced(searcher, debounceMs);
|
|
13716
|
+
}
|
|
13717
|
+
function useCitiesSearch(debounceMs = 300) {
|
|
13718
|
+
const searcher = useCallback17(
|
|
13719
|
+
(q) => getCitiesByName(q),
|
|
13720
|
+
[]
|
|
13721
|
+
);
|
|
13722
|
+
return useDebounced(searcher, debounceMs);
|
|
13723
|
+
}
|
|
13558
13724
|
export {
|
|
13559
13725
|
APP_THEMES,
|
|
13560
13726
|
Accordion,
|
|
@@ -13695,6 +13861,21 @@ export {
|
|
|
13695
13861
|
viewIcon_default as ViewIcon,
|
|
13696
13862
|
workItemIcon_default as WorkItemIcon,
|
|
13697
13863
|
Zoom,
|
|
13864
|
+
getAllCountries2 as getAllCountries,
|
|
13865
|
+
getCitiesByName,
|
|
13866
|
+
getCitiesOfCountry,
|
|
13867
|
+
getCitiesOfState,
|
|
13868
|
+
getCityByName,
|
|
13869
|
+
getCountriesByName,
|
|
13870
|
+
getCountryByCode,
|
|
13871
|
+
getCountryByName,
|
|
13872
|
+
getStateByCode,
|
|
13873
|
+
getStateByName,
|
|
13874
|
+
getStatesByName,
|
|
13875
|
+
getStatesOfCountry,
|
|
13698
13876
|
transformLegacyTodos,
|
|
13699
|
-
|
|
13877
|
+
useCitiesSearch,
|
|
13878
|
+
useCountriesSearch,
|
|
13879
|
+
useRufousTheme,
|
|
13880
|
+
useStatesSearch
|
|
13700
13881
|
};
|