@haloduck/ui 2.0.6 → 2.0.8
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/fesm2022/haloduck-ui.mjs +49 -9
- package/fesm2022/haloduck-ui.mjs.map +1 -1
- package/index.d.ts +6 -1
- package/package.json +1 -1
package/fesm2022/haloduck-ui.mjs
CHANGED
|
@@ -2152,12 +2152,24 @@ class MapToAddressComponent {
|
|
|
2152
2152
|
mapId = this.coreService.getMapId();
|
|
2153
2153
|
defaultLngLat = this.coreService.getDefaultLngLat();
|
|
2154
2154
|
disabled = false;
|
|
2155
|
+
language = 'en';
|
|
2155
2156
|
currentLngLat;
|
|
2156
2157
|
_currentAddress;
|
|
2158
|
+
_isGoogleLoaded = false;
|
|
2159
|
+
_loadError;
|
|
2160
|
+
get isGoogleLoaded() {
|
|
2161
|
+
return this._isGoogleLoaded;
|
|
2162
|
+
}
|
|
2163
|
+
get loadError() {
|
|
2164
|
+
return this._loadError;
|
|
2165
|
+
}
|
|
2157
2166
|
set currentAddress(value) {
|
|
2158
2167
|
if (value) {
|
|
2159
2168
|
this._currentAddress = value;
|
|
2160
|
-
|
|
2169
|
+
// Google Maps API가 로드된 후에만 실행
|
|
2170
|
+
if (this._isGoogleLoaded) {
|
|
2171
|
+
this.setMapToAddress();
|
|
2172
|
+
}
|
|
2161
2173
|
}
|
|
2162
2174
|
}
|
|
2163
2175
|
locationChanged = new EventEmitter();
|
|
@@ -2167,20 +2179,35 @@ class MapToAddressComponent {
|
|
|
2167
2179
|
onChange = () => { };
|
|
2168
2180
|
onTouched = () => { };
|
|
2169
2181
|
async ngOnInit() {
|
|
2170
|
-
|
|
2171
|
-
|
|
2182
|
+
try {
|
|
2183
|
+
await this.initScript();
|
|
2184
|
+
this._isGoogleLoaded = true;
|
|
2185
|
+
this.initMap();
|
|
2186
|
+
// API 로드 완료 후 pending된 주소 설정 실행
|
|
2187
|
+
if (this._currentAddress) {
|
|
2188
|
+
this.setMapToAddress();
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
catch (error) {
|
|
2192
|
+
this._loadError = 'Google Maps API를 로드할 수 없습니다.';
|
|
2193
|
+
isDevMode() && console.error('Failed to load Google Maps API:', error);
|
|
2194
|
+
}
|
|
2172
2195
|
}
|
|
2173
2196
|
initScript() {
|
|
2174
2197
|
return new Promise((resolve, reject) => {
|
|
2175
2198
|
if (typeof google !== 'undefined') {
|
|
2199
|
+
this._isGoogleLoaded = true;
|
|
2176
2200
|
resolve();
|
|
2177
2201
|
return;
|
|
2178
2202
|
}
|
|
2179
2203
|
const script = document.createElement('script');
|
|
2180
|
-
script.src = `https://maps.googleapis.com/maps/api/js?key=${this.coreService.getGoogleApiKey()}&libraries=places,marker&loading=sync`;
|
|
2204
|
+
script.src = `https://maps.googleapis.com/maps/api/js?key=${this.coreService.getGoogleApiKey()}&libraries=places,marker&loading=sync&language=${this.language}`;
|
|
2181
2205
|
script.async = false;
|
|
2182
2206
|
script.defer = true;
|
|
2183
|
-
script.onload = () =>
|
|
2207
|
+
script.onload = () => {
|
|
2208
|
+
this._isGoogleLoaded = true;
|
|
2209
|
+
resolve();
|
|
2210
|
+
};
|
|
2184
2211
|
script.onerror = (error) => reject(error);
|
|
2185
2212
|
document.head.appendChild(script);
|
|
2186
2213
|
isDevMode() && console.log('Google Maps script loaded', script);
|
|
@@ -2256,6 +2283,10 @@ class MapToAddressComponent {
|
|
|
2256
2283
|
}
|
|
2257
2284
|
}
|
|
2258
2285
|
setMapToAddress() {
|
|
2286
|
+
if (!this._isGoogleLoaded) {
|
|
2287
|
+
isDevMode() && console.warn('Google Maps API not loaded yet');
|
|
2288
|
+
return;
|
|
2289
|
+
}
|
|
2259
2290
|
const geocoder = new google.maps.Geocoder();
|
|
2260
2291
|
geocoder.geocode({ address: this._currentAddress }, (results, status) => {
|
|
2261
2292
|
if (status === 'OK' && results[0]) {
|
|
@@ -2269,6 +2300,10 @@ class MapToAddressComponent {
|
|
|
2269
2300
|
});
|
|
2270
2301
|
}
|
|
2271
2302
|
getAddress() {
|
|
2303
|
+
if (!this._isGoogleLoaded) {
|
|
2304
|
+
isDevMode() && console.warn('Google Maps API not loaded yet');
|
|
2305
|
+
return;
|
|
2306
|
+
}
|
|
2272
2307
|
const geocoder = new google.maps.Geocoder();
|
|
2273
2308
|
const position = this.marker.position;
|
|
2274
2309
|
if (!position) {
|
|
@@ -2320,7 +2355,10 @@ class MapToAddressComponent {
|
|
|
2320
2355
|
if (value) {
|
|
2321
2356
|
this.location = value;
|
|
2322
2357
|
this.currentLngLat = { lat: value.lat, lng: value.lng };
|
|
2323
|
-
|
|
2358
|
+
// Google Maps API가 로드된 후에만 맵 초기화
|
|
2359
|
+
if (this._isGoogleLoaded) {
|
|
2360
|
+
this.initializeMap(this.currentLngLat);
|
|
2361
|
+
}
|
|
2324
2362
|
}
|
|
2325
2363
|
}
|
|
2326
2364
|
registerOnChange(fn) {
|
|
@@ -2333,13 +2371,13 @@ class MapToAddressComponent {
|
|
|
2333
2371
|
this.disabled = isDisabled;
|
|
2334
2372
|
}
|
|
2335
2373
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: MapToAddressComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2336
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.4", type: MapToAddressComponent, isStandalone: true, selector: "haloduck-map-to-address", inputs: { disabled: "disabled", currentLngLat: "currentLngLat", currentAddress: "currentAddress" }, outputs: { locationChanged: "locationChanged" }, providers: [
|
|
2374
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.4", type: MapToAddressComponent, isStandalone: true, selector: "haloduck-map-to-address", inputs: { disabled: "disabled", language: "language", currentLngLat: "currentLngLat", currentAddress: "currentAddress" }, outputs: { locationChanged: "locationChanged" }, providers: [
|
|
2337
2375
|
{
|
|
2338
2376
|
provide: NG_VALUE_ACCESSOR,
|
|
2339
2377
|
useExisting: MapToAddressComponent,
|
|
2340
2378
|
multi: true,
|
|
2341
2379
|
},
|
|
2342
|
-
], ngImport: i0, template: "<div id=\"map\" class=\"w-full h-full\"></div
|
|
2380
|
+
], ngImport: i0, template: "<div class=\"w-full h-full relative\">\n <!-- \uB85C\uB529 \uC0C1\uD0DC -->\n <div\n *ngIf=\"!isGoogleLoaded && !loadError\"\n class=\"absolute inset-0 flex items-center justify-center bg-gray-100 z-10\"\n >\n <div class=\"text-center\">\n <div class=\"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mx-auto mb-2\"></div>\n <p class=\"text-gray-600 text-sm\">\uC9C0\uB3C4\uB97C \uB85C\uB529 \uC911\uC785\uB2C8\uB2E4...</p>\n </div>\n </div>\n\n <!-- \uC5D0\uB7EC \uC0C1\uD0DC -->\n <div\n *ngIf=\"loadError\"\n class=\"absolute inset-0 flex items-center justify-center bg-red-50 z-10\"\n >\n <div class=\"text-center p-4\">\n <div class=\"text-red-500 text-2xl mb-2\">\u26A0\uFE0F</div>\n <p class=\"text-red-700 text-sm font-medium\">{{ loadError }}</p>\n <p class=\"text-red-600 text-xs mt-1\">\uC778\uD130\uB137 \uC5F0\uACB0\uC744 \uD655\uC778\uD558\uACE0 \uD398\uC774\uC9C0\uB97C \uC0C8\uB85C\uACE0\uCE68\uD574 \uC8FC\uC138\uC694.</p>\n </div>\n </div>\n\n <div id=\"map\" class=\"w-full h-full\"></div>\n</div>\n", styles: ["#map{border:1px solid #ccc;margin-bottom:10px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: FormsModule }] });
|
|
2343
2381
|
}
|
|
2344
2382
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: MapToAddressComponent, decorators: [{
|
|
2345
2383
|
type: Component,
|
|
@@ -2349,9 +2387,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
|
|
|
2349
2387
|
useExisting: MapToAddressComponent,
|
|
2350
2388
|
multi: true,
|
|
2351
2389
|
},
|
|
2352
|
-
], template: "<div id=\"map\" class=\"w-full h-full\"></div
|
|
2390
|
+
], template: "<div class=\"w-full h-full relative\">\n <!-- \uB85C\uB529 \uC0C1\uD0DC -->\n <div\n *ngIf=\"!isGoogleLoaded && !loadError\"\n class=\"absolute inset-0 flex items-center justify-center bg-gray-100 z-10\"\n >\n <div class=\"text-center\">\n <div class=\"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mx-auto mb-2\"></div>\n <p class=\"text-gray-600 text-sm\">\uC9C0\uB3C4\uB97C \uB85C\uB529 \uC911\uC785\uB2C8\uB2E4...</p>\n </div>\n </div>\n\n <!-- \uC5D0\uB7EC \uC0C1\uD0DC -->\n <div\n *ngIf=\"loadError\"\n class=\"absolute inset-0 flex items-center justify-center bg-red-50 z-10\"\n >\n <div class=\"text-center p-4\">\n <div class=\"text-red-500 text-2xl mb-2\">\u26A0\uFE0F</div>\n <p class=\"text-red-700 text-sm font-medium\">{{ loadError }}</p>\n <p class=\"text-red-600 text-xs mt-1\">\uC778\uD130\uB137 \uC5F0\uACB0\uC744 \uD655\uC778\uD558\uACE0 \uD398\uC774\uC9C0\uB97C \uC0C8\uB85C\uACE0\uCE68\uD574 \uC8FC\uC138\uC694.</p>\n </div>\n </div>\n\n <div id=\"map\" class=\"w-full h-full\"></div>\n</div>\n", styles: ["#map{border:1px solid #ccc;margin-bottom:10px}\n"] }]
|
|
2353
2391
|
}], propDecorators: { disabled: [{
|
|
2354
2392
|
type: Input
|
|
2393
|
+
}], language: [{
|
|
2394
|
+
type: Input
|
|
2355
2395
|
}], currentLngLat: [{
|
|
2356
2396
|
type: Input
|
|
2357
2397
|
}], currentAddress: [{
|