@majoo-ui/react 1.62.3 → 1.62.5
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/index.esm.js +468 -353
- package/package.json +1 -1
- package/src/components/mapPicker/MapPicker.d.ts +0 -1
- package/src/components/mapPicker/components/AddressCard.d.ts +7 -0
- package/src/components/mapPicker/components/ButtonSelect.d.ts +7 -0
- package/src/components/mapPicker/components/ChangeView.d.ts +10 -0
- package/src/components/mapPicker/components/InputSearch.d.ts +3 -0
- package/src/components/mapPicker/components/MarkerIcon.d.ts +2 -0
- package/src/components/mapPicker/components/MarkerSvg.d.ts +2 -0
- package/src/components/mapPicker/components/ZoomControls.d.ts +7 -0
- package/src/components/mapPicker/components/index.d.ts +7 -0
- package/src/components/mapPicker/hooks/useMapSearch.d.ts +39 -0
- package/src/components/mapPicker/types/index.d.ts +36 -44
package/index.esm.js
CHANGED
|
@@ -41,7 +41,7 @@ import { EditableInput, ColorWrap, Saturation, Hue, Alpha, Swatch } from 'react-
|
|
|
41
41
|
import * as color from 'react-color/lib/helpers/color';
|
|
42
42
|
import StepWizard$1 from 'react-step-wizard';
|
|
43
43
|
import { useVirtual } from 'react-virtual';
|
|
44
|
-
import { MapContainer, Circle, TileLayer
|
|
44
|
+
import { useMapEvents, MapContainer, Circle, TileLayer } from '@monsonjeremy/react-leaflet';
|
|
45
45
|
import 'leaflet/dist/leaflet.css';
|
|
46
46
|
import 'leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.css';
|
|
47
47
|
import 'leaflet-defaulticon-compatibility';
|
|
@@ -13594,7 +13594,7 @@ const InputTagsComponent = styled('div', {
|
|
|
13594
13594
|
}
|
|
13595
13595
|
}
|
|
13596
13596
|
});
|
|
13597
|
-
const Input$
|
|
13597
|
+
const Input$7 = styled('input', {
|
|
13598
13598
|
display: 'flex',
|
|
13599
13599
|
position: 'relative',
|
|
13600
13600
|
flex: 'auto',
|
|
@@ -13705,7 +13705,7 @@ function TagsInput(_ref) {
|
|
|
13705
13705
|
disabled: disabled || readOnly || tags.length >= max,
|
|
13706
13706
|
value: value,
|
|
13707
13707
|
css: Object.assign({}, props.css)
|
|
13708
|
-
}, props), /*#__PURE__*/React__default.createElement(Input$
|
|
13708
|
+
}, props), /*#__PURE__*/React__default.createElement(Input$7, {
|
|
13709
13709
|
type: "text",
|
|
13710
13710
|
onKeyUp: event => addTags(event)
|
|
13711
13711
|
// onKeyDown={event => removeTags(tags.length - 1, event.key)}
|
|
@@ -15185,7 +15185,7 @@ const Button$3 = styled('button', {
|
|
|
15185
15185
|
}
|
|
15186
15186
|
}
|
|
15187
15187
|
});
|
|
15188
|
-
const Input$
|
|
15188
|
+
const Input$6 = styled('input', {
|
|
15189
15189
|
marginLeft: '$spacing-05',
|
|
15190
15190
|
display: 'flex',
|
|
15191
15191
|
width: '100%',
|
|
@@ -15361,7 +15361,7 @@ const SelectInputSearch$1 = /*#__PURE__*/React.forwardRef((_a, forwardedRef) =>
|
|
|
15361
15361
|
width: '$spacing-05',
|
|
15362
15362
|
padding: 0
|
|
15363
15363
|
} : undefined
|
|
15364
|
-
}), jsx(Input$
|
|
15364
|
+
}), jsx(Input$6, Object.assign({}, inputProps, props, {
|
|
15365
15365
|
placeholder: placeholder,
|
|
15366
15366
|
readOnly: readOnly,
|
|
15367
15367
|
isReadOnly: readOnly,
|
|
@@ -16425,7 +16425,7 @@ const InputWrapper$1 = styled('div', {
|
|
|
16425
16425
|
}
|
|
16426
16426
|
}
|
|
16427
16427
|
});
|
|
16428
|
-
const Input$
|
|
16428
|
+
const Input$5 = styled('input', {
|
|
16429
16429
|
width: '100%',
|
|
16430
16430
|
textAlign: 'left',
|
|
16431
16431
|
background: 'unset',
|
|
@@ -17305,7 +17305,7 @@ const InputSelectCheck = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
17305
17305
|
suppressRefError: true
|
|
17306
17306
|
}), {
|
|
17307
17307
|
disabled: disabled || readOnly
|
|
17308
|
-
}), /*#__PURE__*/React__default.createElement(Input$
|
|
17308
|
+
}), /*#__PURE__*/React__default.createElement(Input$5, _extends({}, getInputProps({
|
|
17309
17309
|
disabled: disabled || readOnly,
|
|
17310
17310
|
refKey: 'ref',
|
|
17311
17311
|
ref
|
|
@@ -17747,7 +17747,7 @@ const InputWrapper = styled('div', {
|
|
|
17747
17747
|
}
|
|
17748
17748
|
}
|
|
17749
17749
|
});
|
|
17750
|
-
const Input$
|
|
17750
|
+
const Input$4 = styled('input', {
|
|
17751
17751
|
display: 'flex',
|
|
17752
17752
|
position: 'relative',
|
|
17753
17753
|
flex: 'auto',
|
|
@@ -17847,7 +17847,7 @@ function InputCreatable({
|
|
|
17847
17847
|
size: size,
|
|
17848
17848
|
isInvalid: isInvalid,
|
|
17849
17849
|
disabled: disabled || readOnly
|
|
17850
|
-
}, /*#__PURE__*/React__default.createElement(Input$
|
|
17850
|
+
}, /*#__PURE__*/React__default.createElement(Input$4, {
|
|
17851
17851
|
type: "text",
|
|
17852
17852
|
placeholder: placeholder,
|
|
17853
17853
|
disabled: disabled,
|
|
@@ -18345,7 +18345,7 @@ const SelectInputSearch = /*#__PURE__*/React.forwardRef((_a, forwardedRef) => {
|
|
|
18345
18345
|
width: '$spacing-05',
|
|
18346
18346
|
padding: 0
|
|
18347
18347
|
} : undefined
|
|
18348
|
-
}), jsx(Input$
|
|
18348
|
+
}), jsx(Input$6, Object.assign({}, inputProps, props, {
|
|
18349
18349
|
placeholder: placeholder,
|
|
18350
18350
|
readOnly: readOnly,
|
|
18351
18351
|
isReadOnly: readOnly,
|
|
@@ -18532,7 +18532,7 @@ ResendOTP.defaultProps = {
|
|
|
18532
18532
|
timeInterval: 1000
|
|
18533
18533
|
};
|
|
18534
18534
|
|
|
18535
|
-
const Input$
|
|
18535
|
+
const Input$3 = styled(InputNumber, {
|
|
18536
18536
|
border: `1px solid $gray150`,
|
|
18537
18537
|
borderLeft: 'none',
|
|
18538
18538
|
borderRight: 'none',
|
|
@@ -18715,7 +18715,7 @@ const InputCounter = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
18715
18715
|
size: 24,
|
|
18716
18716
|
color: disabled || disabledDecrement ? colors$7.iconDisable : colors$7.primary500
|
|
18717
18717
|
})
|
|
18718
|
-
}), jsx(Input$
|
|
18718
|
+
}), jsx(Input$3, {
|
|
18719
18719
|
ref: ref,
|
|
18720
18720
|
disabled: disabled || disabledIncrement || disabledDecrement || disableManualInput,
|
|
18721
18721
|
disabledChange: disabledIncrement || disabledDecrement || disableManualInput,
|
|
@@ -19471,7 +19471,7 @@ const DateNumber = styled('div', {
|
|
|
19471
19471
|
});
|
|
19472
19472
|
DateNumber.displayName = 'DateNumber';
|
|
19473
19473
|
|
|
19474
|
-
const Input$
|
|
19474
|
+
const Input$2 = styled('input', {
|
|
19475
19475
|
display: 'none'
|
|
19476
19476
|
});
|
|
19477
19477
|
const InputTime = styled('input', {
|
|
@@ -19740,7 +19740,7 @@ const NativeTimePicker = ({
|
|
|
19740
19740
|
type: "up",
|
|
19741
19741
|
disabled: disabled || disabledMinute || disabledMinuteIncrease,
|
|
19742
19742
|
onClick: () => handleUp('minutes')
|
|
19743
|
-
})), /*#__PURE__*/React__default.createElement(Input$
|
|
19743
|
+
})), /*#__PURE__*/React__default.createElement(Input$2, {
|
|
19744
19744
|
type: "time",
|
|
19745
19745
|
defaultValue: moment(date).format(format),
|
|
19746
19746
|
value: value,
|
|
@@ -30478,7 +30478,7 @@ function imgPreview(image_1, crop_1) {
|
|
|
30478
30478
|
}
|
|
30479
30479
|
|
|
30480
30480
|
const _excluded = ["customPreviewIcon"];
|
|
30481
|
-
const Input$
|
|
30481
|
+
const Input$1 = styled('input', {
|
|
30482
30482
|
display: 'none !important'
|
|
30483
30483
|
});
|
|
30484
30484
|
const Children = styled('div', {
|
|
@@ -31328,7 +31328,7 @@ const Upload = ({
|
|
|
31328
31328
|
}, !isFile && renderPicture(), isFile && renderFile(), progress || isLoading ? /*#__PURE__*/React__default.createElement(UploadProgress, {
|
|
31329
31329
|
progress: progress,
|
|
31330
31330
|
loading: loading
|
|
31331
|
-
}) : renderUpload(), showCropper && renderCropper(), /*#__PURE__*/React__default.createElement(Input$
|
|
31331
|
+
}) : renderUpload(), showCropper && renderCropper(), /*#__PURE__*/React__default.createElement(Input$1, {
|
|
31332
31332
|
type: "file",
|
|
31333
31333
|
accept: accept,
|
|
31334
31334
|
ref: hiddenFileInput,
|
|
@@ -52348,7 +52348,7 @@ const RemoveIcon = styled(RemoveOutline, {
|
|
|
52348
52348
|
}
|
|
52349
52349
|
}
|
|
52350
52350
|
});
|
|
52351
|
-
const Input
|
|
52351
|
+
const Input = styled(InputText, {
|
|
52352
52352
|
height: '32px !important'
|
|
52353
52353
|
});
|
|
52354
52354
|
const Required$1 = styled('span', {
|
|
@@ -52765,7 +52765,7 @@ function EditableTable(props) {
|
|
|
52765
52765
|
});
|
|
52766
52766
|
}
|
|
52767
52767
|
EditableTable.Product = Product;
|
|
52768
|
-
EditableTable.Input = Input
|
|
52768
|
+
EditableTable.Input = Input;
|
|
52769
52769
|
EditableTable.Switch = Switch;
|
|
52770
52770
|
EditableTable.Remove = Remove;
|
|
52771
52771
|
EditableTable.TableRow = TableRow$1;
|
|
@@ -53161,13 +53161,14 @@ function ProgressIndicator(props) {
|
|
|
53161
53161
|
return direction === 'horizontal' ? renderHorizontalIndicator() : renderVerticalIndicator();
|
|
53162
53162
|
}
|
|
53163
53163
|
|
|
53164
|
+
//@ts-nocheck
|
|
53164
53165
|
const Container$3 = styled(Flex$1, {
|
|
53165
53166
|
gap: '$spacing-05',
|
|
53166
53167
|
'@md': {
|
|
53167
53168
|
width: 517
|
|
53168
53169
|
}
|
|
53169
53170
|
});
|
|
53170
|
-
const
|
|
53171
|
+
const AddressCardWrapper = styled(Flex$1, {
|
|
53171
53172
|
border: '1px solid #EEF0F0',
|
|
53172
53173
|
borderRadius: 8,
|
|
53173
53174
|
gap: '$spacing-04',
|
|
@@ -53179,7 +53180,7 @@ const Address = styled('p', {
|
|
|
53179
53180
|
color: '$textPrimary',
|
|
53180
53181
|
margin: 0
|
|
53181
53182
|
});
|
|
53182
|
-
const
|
|
53183
|
+
const SearchInput = styled('input', {
|
|
53183
53184
|
boxSizing: `border-box`,
|
|
53184
53185
|
border: `1px solid transparent`,
|
|
53185
53186
|
width: 204,
|
|
@@ -53192,7 +53193,7 @@ const Input = styled('input', {
|
|
|
53192
53193
|
outline: `none`,
|
|
53193
53194
|
textOverflow: `ellipses`
|
|
53194
53195
|
});
|
|
53195
|
-
const
|
|
53196
|
+
const ZoomControlButton = styled(Flex$1, {
|
|
53196
53197
|
height: 44,
|
|
53197
53198
|
width: 44,
|
|
53198
53199
|
padding: 12,
|
|
@@ -53204,97 +53205,65 @@ const ZoomControl = styled(Flex$1, {
|
|
|
53204
53205
|
cursor: 'pointer',
|
|
53205
53206
|
zIndex: 1800
|
|
53206
53207
|
});
|
|
53207
|
-
const
|
|
53208
|
-
|
|
53209
|
-
|
|
53210
|
-
|
|
53211
|
-
|
|
53212
|
-
|
|
53213
|
-
|
|
53214
|
-
|
|
53215
|
-
position: 'absolute',
|
|
53216
|
-
left: 16,
|
|
53217
|
-
top: 16,
|
|
53218
|
-
zIndex: 1000
|
|
53219
|
-
},
|
|
53220
|
-
children: [jsxs(Box, {
|
|
53221
|
-
css: {
|
|
53222
|
-
position: 'relative'
|
|
53223
|
-
},
|
|
53224
|
-
children: [jsx(Input, {
|
|
53225
|
-
placeholder: placeholder,
|
|
53226
|
-
value: value,
|
|
53227
|
-
onChange: onChange
|
|
53228
|
-
}), jsx(Box, {
|
|
53229
|
-
css: {
|
|
53230
|
-
position: 'absolute',
|
|
53231
|
-
top: 5,
|
|
53232
|
-
left: 10
|
|
53233
|
-
},
|
|
53234
|
-
children: jsx(SearchOutline, {
|
|
53235
|
-
size: 24
|
|
53236
|
-
})
|
|
53237
|
-
})]
|
|
53238
|
-
}), list.length ? jsx(Box, {
|
|
53239
|
-
css: {
|
|
53240
|
-
position: 'relative',
|
|
53241
|
-
zIndex: 1000,
|
|
53242
|
-
width: 204,
|
|
53243
|
-
maxHeight: 155,
|
|
53244
|
-
overflow: 'hidden',
|
|
53245
|
-
backgroundColor: '$bgWhite',
|
|
53246
|
-
borderRadius: '$sm'
|
|
53247
|
-
},
|
|
53248
|
-
children: jsx(Flex$1, {
|
|
53249
|
-
direction: "column",
|
|
53250
|
-
gap: 2,
|
|
53251
|
-
children: list.map((item, index) => {
|
|
53252
|
-
return jsx(Paragraph, {
|
|
53253
|
-
css: {
|
|
53254
|
-
cursor: 'pointer',
|
|
53255
|
-
padding: '$spacing-02',
|
|
53256
|
-
'&:hover': {
|
|
53257
|
-
backgroundColor: '$gray100'
|
|
53258
|
-
}
|
|
53259
|
-
},
|
|
53260
|
-
isTruncated: true,
|
|
53261
|
-
onClick: () => onSelect(item),
|
|
53262
|
-
children: item.display_name
|
|
53263
|
-
}, index);
|
|
53264
|
-
})
|
|
53265
|
-
})
|
|
53266
|
-
}) : jsx(Fragment, {})]
|
|
53208
|
+
const MapWrapper = styled('div', {
|
|
53209
|
+
position: 'relative',
|
|
53210
|
+
width: '100% !important',
|
|
53211
|
+
height: '441px !important',
|
|
53212
|
+
overflow: 'hidden',
|
|
53213
|
+
'@md': {
|
|
53214
|
+
width: '517px !important'
|
|
53215
|
+
}
|
|
53267
53216
|
});
|
|
53268
|
-
|
|
53269
|
-
|
|
53270
|
-
|
|
53271
|
-
|
|
53272
|
-
|
|
53273
|
-
|
|
53274
|
-
|
|
53275
|
-
|
|
53276
|
-
|
|
53277
|
-
|
|
53278
|
-
|
|
53279
|
-
|
|
53280
|
-
|
|
53281
|
-
|
|
53282
|
-
|
|
53283
|
-
const [center, setCenter] = useState({
|
|
53217
|
+
const mapContainerStyle = {
|
|
53218
|
+
mobile: {
|
|
53219
|
+
position: 'relative',
|
|
53220
|
+
width: '100%',
|
|
53221
|
+
height: '441px'
|
|
53222
|
+
},
|
|
53223
|
+
desktop: {
|
|
53224
|
+
position: 'relative',
|
|
53225
|
+
width: '517px',
|
|
53226
|
+
height: '441px'
|
|
53227
|
+
}
|
|
53228
|
+
};
|
|
53229
|
+
|
|
53230
|
+
function useMapSearch({
|
|
53231
|
+
initialCenter = {
|
|
53284
53232
|
lat: -6.175392,
|
|
53285
53233
|
lng: 106.827153
|
|
53286
|
-
}
|
|
53234
|
+
},
|
|
53235
|
+
showSelectButton = true,
|
|
53236
|
+
onChange
|
|
53237
|
+
}) {
|
|
53238
|
+
const [center, setCenter] = useState(initialCenter);
|
|
53287
53239
|
const [places, setPlaces] = useState([]);
|
|
53288
53240
|
const [searchQuery, setSearchQuery] = useState('');
|
|
53289
53241
|
const [searchResult, setSearchResult] = useState([]);
|
|
53290
|
-
|
|
53291
|
-
const
|
|
53292
|
-
|
|
53242
|
+
// Track if component is mounted to prevent state updates after unmount
|
|
53243
|
+
const isMountedRef = useRef(true);
|
|
53244
|
+
// AbortController to cancel pending fetch requests
|
|
53245
|
+
const abortControllerRef = useRef(null);
|
|
53246
|
+
// Cleanup on unmount
|
|
53247
|
+
useEffect(() => {
|
|
53248
|
+
isMountedRef.current = true;
|
|
53249
|
+
return () => {
|
|
53250
|
+
var _a;
|
|
53251
|
+
isMountedRef.current = false;
|
|
53252
|
+
// Abort any pending fetch requests
|
|
53253
|
+
(_a = abortControllerRef.current) === null || _a === void 0 ? void 0 : _a.abort();
|
|
53254
|
+
};
|
|
53255
|
+
}, []);
|
|
53256
|
+
const getFullAddress = useCallback((latLng, signal) => __awaiter(this, void 0, void 0, function* () {
|
|
53293
53257
|
try {
|
|
53294
|
-
const res = yield fetch(`https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=${Number(latLng.lat)}&lon=${Number(latLng.lng)}&accept-language=id
|
|
53258
|
+
const res = yield fetch(`https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=${Number(latLng.lat)}&lon=${Number(latLng.lng)}&accept-language=id`, {
|
|
53259
|
+
signal
|
|
53260
|
+
});
|
|
53295
53261
|
const location = yield res.json();
|
|
53296
53262
|
return location;
|
|
53297
53263
|
} catch (error) {
|
|
53264
|
+
if (error.name === 'AbortError') {
|
|
53265
|
+
return null; // Request was cancelled, return null
|
|
53266
|
+
}
|
|
53298
53267
|
throw new Error('Failed to search address');
|
|
53299
53268
|
}
|
|
53300
53269
|
}), []);
|
|
@@ -53305,15 +53274,18 @@ function MapPicker(props) {
|
|
|
53305
53274
|
place_id,
|
|
53306
53275
|
address
|
|
53307
53276
|
}) => {
|
|
53277
|
+
// Only update state if component is still mounted
|
|
53278
|
+
if (!isMountedRef.current) return;
|
|
53308
53279
|
setCenter({
|
|
53309
53280
|
lat: Number(lat),
|
|
53310
53281
|
lng: Number(lon)
|
|
53311
53282
|
});
|
|
53312
53283
|
setPlaces([{
|
|
53313
|
-
lat
|
|
53314
|
-
lon
|
|
53315
|
-
place_id
|
|
53316
|
-
display_name
|
|
53284
|
+
lat,
|
|
53285
|
+
lon,
|
|
53286
|
+
place_id,
|
|
53287
|
+
display_name,
|
|
53288
|
+
address
|
|
53317
53289
|
}]);
|
|
53318
53290
|
setSearchQuery('');
|
|
53319
53291
|
setSearchResult([]);
|
|
@@ -53323,224 +53295,397 @@ function MapPicker(props) {
|
|
|
53323
53295
|
lng: Number(lon),
|
|
53324
53296
|
formatted_address: display_name,
|
|
53325
53297
|
address_components: address
|
|
53326
|
-
});
|
|
53327
|
-
}, [onChange]);
|
|
53298
|
+
}, !showSelectButton);
|
|
53299
|
+
}, [onChange, showSelectButton]);
|
|
53328
53300
|
const handleSearchSelect = useCallback(item => __awaiter(this, void 0, void 0, function* () {
|
|
53301
|
+
var _a;
|
|
53302
|
+
// Cancel any previous pending request
|
|
53303
|
+
(_a = abortControllerRef.current) === null || _a === void 0 ? void 0 : _a.abort();
|
|
53304
|
+
abortControllerRef.current = new AbortController();
|
|
53329
53305
|
const fullAddress = yield getFullAddress({
|
|
53330
53306
|
lat: Number(item.lat),
|
|
53331
53307
|
lng: Number(item.lon)
|
|
53332
|
-
});
|
|
53333
|
-
|
|
53308
|
+
}, abortControllerRef.current.signal);
|
|
53309
|
+
// getFullAddress returns null if aborted
|
|
53310
|
+
if (fullAddress) {
|
|
53311
|
+
handleSelect(fullAddress);
|
|
53312
|
+
}
|
|
53334
53313
|
}), [getFullAddress, handleSelect]);
|
|
53335
53314
|
const handleSearchLatLng = useCallback(latLng => __awaiter(this, void 0, void 0, function* () {
|
|
53336
|
-
|
|
53337
|
-
|
|
53338
|
-
|
|
53339
|
-
|
|
53340
|
-
|
|
53341
|
-
|
|
53342
|
-
|
|
53343
|
-
|
|
53344
|
-
|
|
53345
|
-
|
|
53346
|
-
|
|
53347
|
-
|
|
53348
|
-
|
|
53349
|
-
|
|
53350
|
-
|
|
53351
|
-
|
|
53352
|
-
|
|
53353
|
-
|
|
53354
|
-
|
|
53355
|
-
|
|
53356
|
-
|
|
53357
|
-
useEffect(() => {
|
|
53358
|
-
if (value && (value === null || value === void 0 ? void 0 : value.lat) && (value === null || value === void 0 ? void 0 : value.lng)) {
|
|
53359
|
-
setCenter(value);
|
|
53315
|
+
var _b;
|
|
53316
|
+
// Cancel any previous pending request
|
|
53317
|
+
(_b = abortControllerRef.current) === null || _b === void 0 ? void 0 : _b.abort();
|
|
53318
|
+
abortControllerRef.current = new AbortController();
|
|
53319
|
+
const fullAddress = yield getFullAddress(latLng, abortControllerRef.current.signal);
|
|
53320
|
+
// getFullAddress returns null if aborted
|
|
53321
|
+
if (fullAddress) {
|
|
53322
|
+
const {
|
|
53323
|
+
lat,
|
|
53324
|
+
lon,
|
|
53325
|
+
display_name,
|
|
53326
|
+
place_id,
|
|
53327
|
+
address
|
|
53328
|
+
} = fullAddress;
|
|
53329
|
+
handleSelect({
|
|
53330
|
+
lat,
|
|
53331
|
+
lon,
|
|
53332
|
+
display_name,
|
|
53333
|
+
place_id,
|
|
53334
|
+
address
|
|
53335
|
+
});
|
|
53360
53336
|
}
|
|
53361
|
-
}, [
|
|
53362
|
-
const handleSearch = useCallback(query => __awaiter(this, void 0, void 0, function* () {
|
|
53337
|
+
}), [getFullAddress, handleSelect]);
|
|
53338
|
+
const handleSearch = useCallback((query, signal) => __awaiter(this, void 0, void 0, function* () {
|
|
53363
53339
|
try {
|
|
53364
|
-
const res = yield fetch(`https://nominatim.openstreetmap.org/search.php?q=${query}&polygon_geojson=1&format=jsonv2
|
|
53340
|
+
const res = yield fetch(`https://nominatim.openstreetmap.org/search.php?q=${query}&polygon_geojson=1&format=jsonv2`, {
|
|
53341
|
+
signal
|
|
53342
|
+
});
|
|
53365
53343
|
const result = yield res.json();
|
|
53366
|
-
|
|
53344
|
+
// Only update state if component is still mounted
|
|
53345
|
+
if (isMountedRef.current) {
|
|
53346
|
+
setSearchResult(result);
|
|
53347
|
+
}
|
|
53367
53348
|
} catch (error) {
|
|
53349
|
+
if (error.name === 'AbortError') {
|
|
53350
|
+
return; // Request was cancelled, do nothing
|
|
53351
|
+
}
|
|
53368
53352
|
throw new Error('Failed to search address');
|
|
53369
53353
|
}
|
|
53370
53354
|
}), []);
|
|
53355
|
+
// Debounced search effect
|
|
53371
53356
|
useEffect(() => {
|
|
53372
53357
|
let timeoutId = setTimeout(() => ({}), 1000);
|
|
53358
|
+
const searchAbortController = new AbortController();
|
|
53373
53359
|
clearTimeout(timeoutId);
|
|
53374
53360
|
timeoutId = setTimeout(() => {
|
|
53375
53361
|
if (searchQuery) {
|
|
53376
|
-
handleSearch(searchQuery);
|
|
53362
|
+
handleSearch(searchQuery, searchAbortController.signal);
|
|
53377
53363
|
}
|
|
53378
53364
|
}, 1000);
|
|
53379
|
-
return () =>
|
|
53365
|
+
return () => {
|
|
53366
|
+
clearTimeout(timeoutId);
|
|
53367
|
+
searchAbortController.abort();
|
|
53368
|
+
};
|
|
53380
53369
|
}, [searchQuery, handleSearch]);
|
|
53381
|
-
const
|
|
53382
|
-
|
|
53383
|
-
|
|
53384
|
-
|
|
53385
|
-
|
|
53386
|
-
|
|
53387
|
-
|
|
53388
|
-
|
|
53389
|
-
|
|
53390
|
-
|
|
53391
|
-
|
|
53392
|
-
|
|
53393
|
-
|
|
53394
|
-
|
|
53395
|
-
children: [jsx("feOffset", {
|
|
53396
|
-
in: "SourceAlpha",
|
|
53397
|
-
dx: "0",
|
|
53398
|
-
dy: "1.5",
|
|
53399
|
-
result: "offsetOut"
|
|
53400
|
-
}), jsx("feGaussianBlur", {
|
|
53401
|
-
in: "offsetOut",
|
|
53402
|
-
stdDeviation: "1",
|
|
53403
|
-
result: "blurOut"
|
|
53404
|
-
}), jsx("feBlend", {
|
|
53405
|
-
in: "SourceGraphic",
|
|
53406
|
-
in2: "blurOut",
|
|
53407
|
-
mode: "normal"
|
|
53408
|
-
})]
|
|
53409
|
-
})
|
|
53410
|
-
}), jsxs("g", {
|
|
53411
|
-
filter: "url(#shadow)",
|
|
53412
|
-
children: [jsx("path", {
|
|
53413
|
-
d: "M15.5699 42.6456C15.9031 43.4891 17.0969 43.489 17.4301 42.6456L21.589 32.1174C21.8483 31.4611 21.3646 30.75 20.6589 30.75H12.3411C11.6354 30.75 11.1517 31.4611 11.411 32.1174L15.5699 42.6456Z",
|
|
53414
|
-
fill: "white"
|
|
53415
|
-
}), jsx("rect", {
|
|
53416
|
-
x: "1",
|
|
53417
|
-
y: "1",
|
|
53418
|
-
width: "31",
|
|
53419
|
-
height: "31",
|
|
53420
|
-
rx: "15.5",
|
|
53421
|
-
fill: "#04C99E"
|
|
53422
|
-
}), jsx("path", {
|
|
53423
|
-
fillRule: "evenodd",
|
|
53424
|
-
clipRule: "evenodd",
|
|
53425
|
-
d: "M24.5117 21.7932C24.5117 22.8679 23.6672 23.7355 22.6211 23.7355C21.5749 23.7355 20.7304 22.8679 20.7304 21.7932C20.7304 19.4107 20.7304 17.0411 20.7304 14.6715C21.0454 14.6715 21.3606 14.6715 21.6757 14.6715C21.9026 14.6715 22.016 14.4643 21.8522 14.283C21.1211 13.4025 20.3774 12.535 19.6464 11.6545C19.4573 11.3955 19.3943 11.4473 19.2179 11.6545C18.4868 12.535 17.7432 13.4025 17.0121 14.283C16.8483 14.4773 16.9617 14.6715 17.1886 14.6715C17.5037 14.6715 17.8188 14.6715 18.1339 14.6715C18.1339 17.0541 18.1465 19.4107 18.1465 21.7932C18.1465 22.8679 17.302 23.7355 16.2558 23.7355C15.2097 23.7355 14.3652 22.8679 14.3652 21.7932C14.3652 20.1229 14.3778 18.4655 14.3778 16.808C14.6929 16.808 15.008 16.808 15.3231 16.808C15.55 16.808 15.6634 16.6009 15.4996 16.4196C14.7685 15.5391 14.0249 14.6715 13.2938 13.791C13.1048 13.532 13.0417 13.5838 12.8653 13.791C12.1342 14.6715 11.3906 15.5391 10.6595 16.4196C10.4957 16.6138 10.6091 16.808 10.836 16.808C11.1511 16.808 11.4662 16.808 11.7813 16.808V16.8987V21.7932C11.7813 22.8679 10.9368 23.7355 9.89065 23.7355C8.84449 23.7355 8 22.8679 8 21.7932V14.2054C8 12.781 8.56719 11.4732 9.48731 10.5279C10.4074 9.5827 11.6805 9.00001 13.0796 9.00001C14.2896 9.00001 15.3988 9.44027 16.2684 10.1654C17.1381 9.44027 18.2473 9.00001 19.4573 9.00001C20.8565 9.00001 22.1295 9.5827 23.0496 10.5279C23.9697 11.4732 24.5369 12.781 24.5369 14.2054V21.7932H24.5117Z",
|
|
53426
|
-
fill: "white"
|
|
53427
|
-
}), jsx("rect", {
|
|
53428
|
-
x: "1",
|
|
53429
|
-
y: "1",
|
|
53430
|
-
width: "31",
|
|
53431
|
-
height: "31",
|
|
53432
|
-
rx: "15.5",
|
|
53433
|
-
stroke: "white",
|
|
53434
|
-
strokeWidth: "2"
|
|
53435
|
-
})]
|
|
53436
|
-
})]
|
|
53437
|
-
});
|
|
53370
|
+
const handleSearchChange = useCallback(e => {
|
|
53371
|
+
const val = e.target.value;
|
|
53372
|
+
setSearchQuery(val);
|
|
53373
|
+
}, []);
|
|
53374
|
+
return {
|
|
53375
|
+
center,
|
|
53376
|
+
setCenter,
|
|
53377
|
+
places,
|
|
53378
|
+
searchQuery,
|
|
53379
|
+
searchResult,
|
|
53380
|
+
handleSearchChange,
|
|
53381
|
+
handleSearchSelect,
|
|
53382
|
+
handleSearchLatLng,
|
|
53383
|
+
getFullAddress
|
|
53438
53384
|
};
|
|
53439
|
-
|
|
53440
|
-
|
|
53441
|
-
|
|
53442
|
-
|
|
53443
|
-
|
|
53444
|
-
|
|
53445
|
-
|
|
53385
|
+
}
|
|
53386
|
+
|
|
53387
|
+
function InputSearch({
|
|
53388
|
+
placeholder,
|
|
53389
|
+
value,
|
|
53390
|
+
list,
|
|
53391
|
+
onChange,
|
|
53392
|
+
onSelect
|
|
53393
|
+
}) {
|
|
53394
|
+
return jsxs(Box, {
|
|
53395
|
+
css: {
|
|
53396
|
+
position: 'absolute',
|
|
53397
|
+
left: 16,
|
|
53398
|
+
top: 16,
|
|
53399
|
+
zIndex: 1000
|
|
53400
|
+
},
|
|
53401
|
+
children: [jsxs(Box, {
|
|
53446
53402
|
css: {
|
|
53447
|
-
position: '
|
|
53448
|
-
top: '34%',
|
|
53449
|
-
left: '22%',
|
|
53450
|
-
zIndex: 1000,
|
|
53451
|
-
'@md': {
|
|
53452
|
-
left: '32%'
|
|
53453
|
-
}
|
|
53403
|
+
position: 'relative'
|
|
53454
53404
|
},
|
|
53455
|
-
children:
|
|
53456
|
-
|
|
53457
|
-
|
|
53405
|
+
children: [jsx(SearchInput, {
|
|
53406
|
+
placeholder: placeholder,
|
|
53407
|
+
value: value,
|
|
53408
|
+
onChange: onChange
|
|
53409
|
+
}), jsx(Box, {
|
|
53458
53410
|
css: {
|
|
53459
|
-
|
|
53460
|
-
|
|
53461
|
-
|
|
53462
|
-
fontWeight: 600,
|
|
53463
|
-
color: '$textWhite',
|
|
53464
|
-
padding: '4px 12px',
|
|
53465
|
-
height: 28,
|
|
53466
|
-
cursor: 'pointer'
|
|
53411
|
+
position: 'absolute',
|
|
53412
|
+
top: 5,
|
|
53413
|
+
left: 10
|
|
53467
53414
|
},
|
|
53468
|
-
|
|
53469
|
-
|
|
53470
|
-
|
|
53471
|
-
|
|
53472
|
-
|
|
53473
|
-
children: jsx(ChevronRightOutline, {
|
|
53474
|
-
color: "#FFFFFF"
|
|
53475
|
-
})
|
|
53476
|
-
})]
|
|
53477
|
-
})
|
|
53478
|
-
});
|
|
53479
|
-
}
|
|
53480
|
-
function MarkerIcon() {
|
|
53481
|
-
return jsx(Box, {
|
|
53415
|
+
children: jsx(SearchOutline, {
|
|
53416
|
+
size: 24
|
|
53417
|
+
})
|
|
53418
|
+
})]
|
|
53419
|
+
}), list.length ? jsx(Box, {
|
|
53482
53420
|
css: {
|
|
53483
|
-
position: '
|
|
53484
|
-
top: '40%',
|
|
53485
|
-
left: '46%',
|
|
53421
|
+
position: 'relative',
|
|
53486
53422
|
zIndex: 1000,
|
|
53487
|
-
|
|
53488
|
-
|
|
53489
|
-
|
|
53423
|
+
width: 204,
|
|
53424
|
+
maxHeight: 155,
|
|
53425
|
+
overflow: 'hidden',
|
|
53426
|
+
backgroundColor: '$bgWhite',
|
|
53427
|
+
borderRadius: '$sm'
|
|
53490
53428
|
},
|
|
53491
|
-
children: jsx(
|
|
53492
|
-
|
|
53493
|
-
|
|
53494
|
-
|
|
53495
|
-
|
|
53496
|
-
|
|
53497
|
-
|
|
53498
|
-
|
|
53499
|
-
|
|
53500
|
-
|
|
53501
|
-
|
|
53502
|
-
|
|
53503
|
-
|
|
53504
|
-
|
|
53429
|
+
children: jsx(Flex$1, {
|
|
53430
|
+
direction: "column",
|
|
53431
|
+
gap: 2,
|
|
53432
|
+
children: list.map((item, index) => {
|
|
53433
|
+
return jsx(Paragraph, {
|
|
53434
|
+
css: {
|
|
53435
|
+
cursor: 'pointer',
|
|
53436
|
+
padding: '$spacing-02',
|
|
53437
|
+
'&:hover': {
|
|
53438
|
+
backgroundColor: '$gray100'
|
|
53439
|
+
}
|
|
53440
|
+
},
|
|
53441
|
+
isTruncated: true,
|
|
53442
|
+
onClick: () => onSelect(item),
|
|
53443
|
+
children: item.display_name
|
|
53444
|
+
}, index);
|
|
53445
|
+
})
|
|
53446
|
+
})
|
|
53447
|
+
}) : jsx(Fragment, {})]
|
|
53448
|
+
});
|
|
53449
|
+
}
|
|
53450
|
+
|
|
53451
|
+
function ButtonSelect({
|
|
53452
|
+
onClick,
|
|
53453
|
+
label = 'Gunakan Lokasi Ini'
|
|
53454
|
+
}) {
|
|
53455
|
+
return jsx(Box, {
|
|
53456
|
+
css: {
|
|
53457
|
+
position: 'absolute',
|
|
53458
|
+
top: '34%',
|
|
53459
|
+
left: '22%',
|
|
53460
|
+
zIndex: 1000,
|
|
53461
|
+
'@md': {
|
|
53462
|
+
left: '32%'
|
|
53505
53463
|
}
|
|
53506
|
-
}
|
|
53507
|
-
|
|
53508
|
-
|
|
53509
|
-
|
|
53510
|
-
return jsxs(Container$3, {
|
|
53511
|
-
direction: "column",
|
|
53512
|
-
css: css,
|
|
53513
|
-
children: [showBanner && isBanner && jsxs(Banner, {
|
|
53464
|
+
},
|
|
53465
|
+
children: jsxs(Flex$1, {
|
|
53466
|
+
align: "center",
|
|
53467
|
+
gap: 3,
|
|
53514
53468
|
css: {
|
|
53515
|
-
|
|
53469
|
+
backgroundColor: '$btnPrimary',
|
|
53470
|
+
borderRadius: 6,
|
|
53471
|
+
fontSize: 16,
|
|
53472
|
+
fontWeight: 600,
|
|
53473
|
+
color: '$textWhite',
|
|
53474
|
+
padding: '4px 12px',
|
|
53475
|
+
height: 28,
|
|
53476
|
+
cursor: 'pointer'
|
|
53516
53477
|
},
|
|
53517
|
-
|
|
53518
|
-
|
|
53519
|
-
onRemove: () => setIsBanner(false),
|
|
53520
|
-
children: [jsx(Paragraph, {
|
|
53478
|
+
onClick: onClick,
|
|
53479
|
+
children: [label, jsx(Box, {
|
|
53521
53480
|
css: {
|
|
53522
|
-
|
|
53481
|
+
marginTop: 3
|
|
53523
53482
|
},
|
|
53524
|
-
|
|
53525
|
-
|
|
53526
|
-
|
|
53527
|
-
})
|
|
53528
|
-
})
|
|
53483
|
+
children: jsx(ChevronRightOutline, {
|
|
53484
|
+
color: "#FFFFFF"
|
|
53485
|
+
})
|
|
53486
|
+
})]
|
|
53487
|
+
})
|
|
53488
|
+
});
|
|
53489
|
+
}
|
|
53490
|
+
|
|
53491
|
+
function MarkerSvg() {
|
|
53492
|
+
return jsxs("svg", {
|
|
53493
|
+
width: "33",
|
|
53494
|
+
height: "46",
|
|
53495
|
+
viewBox: "0 0 33 46",
|
|
53496
|
+
fill: "none",
|
|
53497
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
53498
|
+
children: [jsx("defs", {
|
|
53499
|
+
children: jsxs("filter", {
|
|
53500
|
+
id: "shadow",
|
|
53501
|
+
x: "-10%",
|
|
53502
|
+
y: "-10%",
|
|
53503
|
+
width: "120%",
|
|
53504
|
+
height: "120%",
|
|
53505
|
+
children: [jsx("feOffset", {
|
|
53506
|
+
in: "SourceAlpha",
|
|
53507
|
+
dx: "0",
|
|
53508
|
+
dy: "1.5",
|
|
53509
|
+
result: "offsetOut"
|
|
53510
|
+
}), jsx("feGaussianBlur", {
|
|
53511
|
+
in: "offsetOut",
|
|
53512
|
+
stdDeviation: "1",
|
|
53513
|
+
result: "blurOut"
|
|
53514
|
+
}), jsx("feBlend", {
|
|
53515
|
+
in: "SourceGraphic",
|
|
53516
|
+
in2: "blurOut",
|
|
53517
|
+
mode: "normal"
|
|
53518
|
+
})]
|
|
53519
|
+
})
|
|
53520
|
+
}), jsxs("g", {
|
|
53521
|
+
filter: "url(#shadow)",
|
|
53522
|
+
children: [jsx("path", {
|
|
53523
|
+
d: "M15.5699 42.6456C15.9031 43.4891 17.0969 43.489 17.4301 42.6456L21.589 32.1174C21.8483 31.4611 21.3646 30.75 20.6589 30.75H12.3411C11.6354 30.75 11.1517 31.4611 11.411 32.1174L15.5699 42.6456Z",
|
|
53524
|
+
fill: "white"
|
|
53525
|
+
}), jsx("rect", {
|
|
53526
|
+
x: "1",
|
|
53527
|
+
y: "1",
|
|
53528
|
+
width: "31",
|
|
53529
|
+
height: "31",
|
|
53530
|
+
rx: "15.5",
|
|
53531
|
+
fill: "#04C99E"
|
|
53532
|
+
}), jsx("path", {
|
|
53533
|
+
fillRule: "evenodd",
|
|
53534
|
+
clipRule: "evenodd",
|
|
53535
|
+
d: "M24.5117 21.7932C24.5117 22.8679 23.6672 23.7355 22.6211 23.7355C21.5749 23.7355 20.7304 22.8679 20.7304 21.7932C20.7304 19.4107 20.7304 17.0411 20.7304 14.6715C21.0454 14.6715 21.3606 14.6715 21.6757 14.6715C21.9026 14.6715 22.016 14.4643 21.8522 14.283C21.1211 13.4025 20.3774 12.535 19.6464 11.6545C19.4573 11.3955 19.3943 11.4473 19.2179 11.6545C18.4868 12.535 17.7432 13.4025 17.0121 14.283C16.8483 14.4773 16.9617 14.6715 17.1886 14.6715C17.5037 14.6715 17.8188 14.6715 18.1339 14.6715C18.1339 17.0541 18.1465 19.4107 18.1465 21.7932C18.1465 22.8679 17.302 23.7355 16.2558 23.7355C15.2097 23.7355 14.3652 22.8679 14.3652 21.7932C14.3652 20.1229 14.3778 18.4655 14.3778 16.808C14.6929 16.808 15.008 16.808 15.3231 16.808C15.55 16.808 15.6634 16.6009 15.4996 16.4196C14.7685 15.5391 14.0249 14.6715 13.2938 13.791C13.1048 13.532 13.0417 13.5838 12.8653 13.791C12.1342 14.6715 11.3906 15.5391 10.6595 16.4196C10.4957 16.6138 10.6091 16.808 10.836 16.808C11.1511 16.808 11.4662 16.808 11.7813 16.808V16.8987V21.7932C11.7813 22.8679 10.9368 23.7355 9.89065 23.7355C8.84449 23.7355 8 22.8679 8 21.7932V14.2054C8 12.781 8.56719 11.4732 9.48731 10.5279C10.4074 9.5827 11.6805 9.00001 13.0796 9.00001C14.2896 9.00001 15.3988 9.44027 16.2684 10.1654C17.1381 9.44027 18.2473 9.00001 19.4573 9.00001C20.8565 9.00001 22.1295 9.5827 23.0496 10.5279C23.9697 11.4732 24.5369 12.781 24.5369 14.2054V21.7932H24.5117Z",
|
|
53536
|
+
fill: "white"
|
|
53537
|
+
}), jsx("rect", {
|
|
53538
|
+
x: "1",
|
|
53539
|
+
y: "1",
|
|
53540
|
+
width: "31",
|
|
53541
|
+
height: "31",
|
|
53542
|
+
rx: "15.5",
|
|
53543
|
+
stroke: "white",
|
|
53544
|
+
strokeWidth: "2"
|
|
53545
|
+
})]
|
|
53546
|
+
})]
|
|
53547
|
+
});
|
|
53548
|
+
}
|
|
53549
|
+
|
|
53550
|
+
function MarkerIcon() {
|
|
53551
|
+
return jsx(Box, {
|
|
53552
|
+
css: {
|
|
53553
|
+
position: 'absolute',
|
|
53554
|
+
top: '40%',
|
|
53555
|
+
left: '46%',
|
|
53556
|
+
zIndex: 1000,
|
|
53557
|
+
'@md': {
|
|
53558
|
+
left: '47%'
|
|
53559
|
+
}
|
|
53560
|
+
},
|
|
53561
|
+
children: jsx(MarkerSvg, {})
|
|
53562
|
+
});
|
|
53563
|
+
}
|
|
53564
|
+
|
|
53565
|
+
function ZoomControls({
|
|
53566
|
+
onZoomIn,
|
|
53567
|
+
onZoomOut
|
|
53568
|
+
}) {
|
|
53569
|
+
return jsxs(Flex$1, {
|
|
53570
|
+
direction: "column",
|
|
53571
|
+
gap: 2,
|
|
53572
|
+
css: {
|
|
53573
|
+
position: 'absolute',
|
|
53574
|
+
bottom: 16,
|
|
53575
|
+
right: 16,
|
|
53576
|
+
zIndex: 1000
|
|
53577
|
+
},
|
|
53578
|
+
children: [jsx(ZoomControlButton, {
|
|
53579
|
+
onClick: onZoomIn,
|
|
53580
|
+
children: jsx(PlusOutline, {
|
|
53581
|
+
size: 20,
|
|
53582
|
+
color: "#04C99E"
|
|
53583
|
+
})
|
|
53584
|
+
}), jsx(ZoomControlButton, {
|
|
53585
|
+
onClick: onZoomOut,
|
|
53586
|
+
children: jsx(MinusOutline, {
|
|
53587
|
+
size: 20,
|
|
53588
|
+
color: "#04C99E"
|
|
53589
|
+
})
|
|
53590
|
+
})]
|
|
53591
|
+
});
|
|
53592
|
+
}
|
|
53593
|
+
|
|
53594
|
+
function AddressCard({
|
|
53595
|
+
place
|
|
53596
|
+
}) {
|
|
53597
|
+
return jsxs(AddressCardWrapper, {
|
|
53598
|
+
align: "center",
|
|
53599
|
+
children: [jsx(Box, {
|
|
53529
53600
|
css: {
|
|
53530
|
-
|
|
53531
|
-
|
|
53532
|
-
height: '441px !important',
|
|
53533
|
-
overflow: 'hidden'
|
|
53601
|
+
width: 24,
|
|
53602
|
+
height: 24
|
|
53534
53603
|
},
|
|
53604
|
+
children: jsx(LocationOutline, {
|
|
53605
|
+
size: 24
|
|
53606
|
+
})
|
|
53607
|
+
}), ' ', jsx(Address, {
|
|
53608
|
+
children: place.display_name
|
|
53609
|
+
})]
|
|
53610
|
+
}, place.place_id);
|
|
53611
|
+
}
|
|
53612
|
+
|
|
53613
|
+
//@ts-nocheck
|
|
53614
|
+
function ChangeView({
|
|
53615
|
+
center,
|
|
53616
|
+
readOnly,
|
|
53617
|
+
onDragEnd
|
|
53618
|
+
}) {
|
|
53619
|
+
const map = useMapEvents({
|
|
53620
|
+
dragend: e => {
|
|
53621
|
+
if (readOnly) return;
|
|
53622
|
+
const latLng = e.target.getCenter();
|
|
53623
|
+
onDragEnd(latLng);
|
|
53624
|
+
}
|
|
53625
|
+
});
|
|
53626
|
+
map.setView(center, map.getZoom());
|
|
53627
|
+
return null;
|
|
53628
|
+
}
|
|
53629
|
+
|
|
53630
|
+
function MapPicker(props) {
|
|
53631
|
+
const {
|
|
53632
|
+
css,
|
|
53633
|
+
radius,
|
|
53634
|
+
value,
|
|
53635
|
+
showSelectButton,
|
|
53636
|
+
readOnly,
|
|
53637
|
+
onChange,
|
|
53638
|
+
selectLocationText,
|
|
53639
|
+
searchPlaceholder,
|
|
53640
|
+
header
|
|
53641
|
+
} = props;
|
|
53642
|
+
const [zoom, setZoom] = useState(16);
|
|
53643
|
+
const isDesktop = useMediaQuery('(min-width: 767px)');
|
|
53644
|
+
const {
|
|
53645
|
+
center,
|
|
53646
|
+
setCenter,
|
|
53647
|
+
places,
|
|
53648
|
+
searchQuery,
|
|
53649
|
+
searchResult,
|
|
53650
|
+
handleSearchChange,
|
|
53651
|
+
handleSearchSelect,
|
|
53652
|
+
handleSearchLatLng
|
|
53653
|
+
} = useMapSearch({
|
|
53654
|
+
initialCenter: value && (value === null || value === void 0 ? void 0 : value.lat) && (value === null || value === void 0 ? void 0 : value.lng) && value || {
|
|
53655
|
+
lat: -6.175392,
|
|
53656
|
+
lng: 106.827153
|
|
53657
|
+
},
|
|
53658
|
+
showSelectButton,
|
|
53659
|
+
onChange
|
|
53660
|
+
});
|
|
53661
|
+
useEffect(() => {
|
|
53662
|
+
if (value && (value === null || value === void 0 ? void 0 : value.lat) && (value === null || value === void 0 ? void 0 : value.lng)) {
|
|
53663
|
+
setCenter(value);
|
|
53664
|
+
handleSearchLatLng(value);
|
|
53665
|
+
}
|
|
53666
|
+
}, [value, setCenter]);
|
|
53667
|
+
function handleMarkerClick() {
|
|
53668
|
+
if (places.length > 0) {
|
|
53669
|
+
const mapObject = {
|
|
53670
|
+
place_id: places[0].place_id,
|
|
53671
|
+
lat: places[0].lat,
|
|
53672
|
+
lng: places[0].lon,
|
|
53673
|
+
formatted_address: places[0].display_name,
|
|
53674
|
+
address_components: places[0].address
|
|
53675
|
+
};
|
|
53676
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(Object.assign({}, mapObject), true);
|
|
53677
|
+
}
|
|
53678
|
+
}
|
|
53679
|
+
return jsxs(Container$3, {
|
|
53680
|
+
direction: "column",
|
|
53681
|
+
css: css,
|
|
53682
|
+
children: [header, jsx(MapWrapper, {
|
|
53535
53683
|
children: jsxs(MapContainer, {
|
|
53536
53684
|
center: [center === null || center === void 0 ? void 0 : center.lat, center === null || center === void 0 ? void 0 : center.lng],
|
|
53537
53685
|
zoom: zoom,
|
|
53538
53686
|
zoomControl: false,
|
|
53539
|
-
|
|
53540
|
-
|
|
53541
|
-
width: isDesktop ? '517px' : '100%',
|
|
53542
|
-
height: '441px'
|
|
53543
|
-
},
|
|
53687
|
+
dragging: !readOnly,
|
|
53688
|
+
style: isDesktop ? mapContainerStyle.desktop : mapContainerStyle.mobile,
|
|
53544
53689
|
children: [radius && jsx(Circle, {
|
|
53545
53690
|
center: [center === null || center === void 0 ? void 0 : center.lat, center === null || center === void 0 ? void 0 : center.lng],
|
|
53546
53691
|
radius: radius,
|
|
@@ -53550,61 +53695,30 @@ function MapPicker(props) {
|
|
|
53550
53695
|
}
|
|
53551
53696
|
}), jsx(TileLayer, {
|
|
53552
53697
|
url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
53553
|
-
}), showSelectButton && jsx(ButtonSelect, {
|
|
53554
|
-
|
|
53555
|
-
|
|
53698
|
+
}), showSelectButton && jsx(ButtonSelect, {
|
|
53699
|
+
onClick: handleMarkerClick,
|
|
53700
|
+
label: selectLocationText
|
|
53701
|
+
}), jsx(MarkerIcon, {}), jsx(ChangeView, {
|
|
53702
|
+
center: [center === null || center === void 0 ? void 0 : center.lat, center === null || center === void 0 ? void 0 : center.lng],
|
|
53703
|
+
readOnly: readOnly,
|
|
53704
|
+
onDragEnd: handleSearchLatLng
|
|
53705
|
+
}), !readOnly && jsx(InputSearch, {
|
|
53556
53706
|
list: searchResult,
|
|
53557
53707
|
value: searchQuery,
|
|
53558
|
-
placeholder:
|
|
53708
|
+
placeholder: searchPlaceholder || 'Cari ...',
|
|
53559
53709
|
onChange: handleSearchChange,
|
|
53560
53710
|
onSelect: handleSearchSelect
|
|
53561
|
-
}),
|
|
53562
|
-
|
|
53563
|
-
|
|
53564
|
-
css: {
|
|
53565
|
-
position: 'absolute',
|
|
53566
|
-
bottom: 16,
|
|
53567
|
-
right: 16,
|
|
53568
|
-
zIndex: 1000
|
|
53569
|
-
},
|
|
53570
|
-
children: [jsx(ZoomControl, {
|
|
53571
|
-
onClick: () => setZoom(current => current + 1),
|
|
53572
|
-
children: jsx(PlusOutline, {
|
|
53573
|
-
size: 20,
|
|
53574
|
-
color: "#04C99E"
|
|
53575
|
-
})
|
|
53576
|
-
}), jsx(ZoomControl, {
|
|
53577
|
-
onClick: () => setZoom(current => current - 1),
|
|
53578
|
-
children: jsx(MinusOutline, {
|
|
53579
|
-
size: 20,
|
|
53580
|
-
color: "#04C99E"
|
|
53581
|
-
})
|
|
53582
|
-
})]
|
|
53711
|
+
}), jsx(ZoomControls, {
|
|
53712
|
+
onZoomIn: () => setZoom(current => current + 1),
|
|
53713
|
+
onZoomOut: () => setZoom(current => current - 1)
|
|
53583
53714
|
})]
|
|
53584
53715
|
}, zoom)
|
|
53585
|
-
}), places === null || places === void 0 ? void 0 : places.map(({
|
|
53586
|
-
|
|
53587
|
-
|
|
53588
|
-
}) => {
|
|
53589
|
-
return jsxs(AddressCard, {
|
|
53590
|
-
align: "center",
|
|
53591
|
-
children: [jsx(Box, {
|
|
53592
|
-
css: {
|
|
53593
|
-
width: 24,
|
|
53594
|
-
height: 24
|
|
53595
|
-
},
|
|
53596
|
-
children: jsx(LocationOutline, {
|
|
53597
|
-
size: 24
|
|
53598
|
-
})
|
|
53599
|
-
}), ' ', jsx(Address, {
|
|
53600
|
-
children: display_name
|
|
53601
|
-
})]
|
|
53602
|
-
}, place_id);
|
|
53603
|
-
})]
|
|
53716
|
+
}), places === null || places === void 0 ? void 0 : places.map(place => jsx(AddressCard, {
|
|
53717
|
+
place: place
|
|
53718
|
+
}, place.place_id))]
|
|
53604
53719
|
});
|
|
53605
53720
|
}
|
|
53606
53721
|
MapPicker.defaultProps = {
|
|
53607
|
-
showBanner: true,
|
|
53608
53722
|
value: {
|
|
53609
53723
|
lat: -6.175392,
|
|
53610
53724
|
lng: 106.827153
|
|
@@ -53622,29 +53736,27 @@ const ContainerInput = styled('div', {
|
|
|
53622
53736
|
});
|
|
53623
53737
|
function InputMapPicker(props) {
|
|
53624
53738
|
var _a;
|
|
53625
|
-
const {
|
|
53626
|
-
t
|
|
53627
|
-
} = useTranslation(['MajooUI/mapPicker', 'translation']);
|
|
53628
53739
|
const {
|
|
53629
53740
|
css,
|
|
53630
53741
|
modalTitle,
|
|
53631
53742
|
buttonLabel,
|
|
53632
53743
|
placeholder,
|
|
53633
|
-
showBanner,
|
|
53634
|
-
bannerDescription,
|
|
53635
53744
|
radius,
|
|
53636
53745
|
value,
|
|
53637
53746
|
showSelectButton,
|
|
53747
|
+
readOnly,
|
|
53638
53748
|
onChange,
|
|
53639
|
-
|
|
53640
|
-
|
|
53749
|
+
customInputValue,
|
|
53750
|
+
header
|
|
53641
53751
|
} = props;
|
|
53642
53752
|
const modalTrigger = React__default.useRef(null);
|
|
53643
53753
|
const [inputValue, setInputValue] = useState(placeholder);
|
|
53754
|
+
const initialInputValue = useRef(null);
|
|
53644
53755
|
const handleSearchLatLng = useCallback(latLng => __awaiter(this, void 0, void 0, function* () {
|
|
53645
53756
|
try {
|
|
53646
53757
|
const res = yield fetch(`https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=${Number(latLng.lat)}&lon=${Number(latLng.lng)}&accept-language=id`);
|
|
53647
53758
|
const location = yield res.json();
|
|
53759
|
+
initialInputValue.current = location.display_name;
|
|
53648
53760
|
setInputValue(location.display_name);
|
|
53649
53761
|
} catch (error) {
|
|
53650
53762
|
throw new Error('Failed to search address');
|
|
@@ -53659,13 +53771,13 @@ function InputMapPicker(props) {
|
|
|
53659
53771
|
var _a;
|
|
53660
53772
|
(_a = modalTrigger === null || modalTrigger === void 0 ? void 0 : modalTrigger.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
53661
53773
|
}
|
|
53662
|
-
function
|
|
53663
|
-
|
|
53664
|
-
|
|
53665
|
-
|
|
53666
|
-
|
|
53667
|
-
|
|
53668
|
-
|
|
53774
|
+
function handleChange(mapObject, isConfirmed) {
|
|
53775
|
+
if (isConfirmed) {
|
|
53776
|
+
handleClick();
|
|
53777
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(mapObject);
|
|
53778
|
+
} else {
|
|
53779
|
+
setInputValue(mapObject.formatted_address);
|
|
53780
|
+
}
|
|
53669
53781
|
}
|
|
53670
53782
|
const isDesktop = useMediaQuery('(min-width: 767px)');
|
|
53671
53783
|
return jsxs(React__default.Fragment, {
|
|
@@ -53708,13 +53820,13 @@ function InputMapPicker(props) {
|
|
|
53708
53820
|
flex: 1
|
|
53709
53821
|
},
|
|
53710
53822
|
isTruncated: true,
|
|
53711
|
-
children: (_a = customInputValue !== null && customInputValue !== void 0 ? customInputValue : inputValue) !== null && _a !== void 0 ? _a :
|
|
53823
|
+
children: (_a = customInputValue !== null && customInputValue !== void 0 ? customInputValue : inputValue) !== null && _a !== void 0 ? _a : 'Tandai lokasi dalam peta'
|
|
53712
53824
|
}), isDesktop ? jsx(Button$4, {
|
|
53713
53825
|
type: "button",
|
|
53714
53826
|
size: "sm",
|
|
53715
53827
|
buttonType: "secondary",
|
|
53716
53828
|
onClick: handleClick,
|
|
53717
|
-
children: buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel :
|
|
53829
|
+
children: buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel : 'Ubah Lokasi'
|
|
53718
53830
|
}) : null]
|
|
53719
53831
|
})
|
|
53720
53832
|
})]
|
|
@@ -53723,19 +53835,23 @@ function InputMapPicker(props) {
|
|
|
53723
53835
|
size: "md",
|
|
53724
53836
|
buttonType: "secondary",
|
|
53725
53837
|
onClick: handleClick,
|
|
53726
|
-
children: buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel :
|
|
53838
|
+
children: buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel : 'Ubah Lokasi'
|
|
53727
53839
|
}) : null]
|
|
53728
53840
|
}), jsxs(ModalDialog, {
|
|
53729
53841
|
width: isDesktop ? 565 : '100%',
|
|
53730
53842
|
layer: "$modal",
|
|
53731
53843
|
onPointerDownOutside: e => e.preventDefault(),
|
|
53844
|
+
onCloseClick: () => {
|
|
53845
|
+
var _a;
|
|
53846
|
+
return setInputValue((_a = initialInputValue.current) !== null && _a !== void 0 ? _a : placeholder);
|
|
53847
|
+
},
|
|
53732
53848
|
children: [jsx(ModalDialogTrigger, {
|
|
53733
53849
|
asChild: true,
|
|
53734
53850
|
children: jsx("div", {
|
|
53735
53851
|
ref: modalTrigger
|
|
53736
53852
|
})
|
|
53737
53853
|
}), jsx(ModalDialogTitle, {
|
|
53738
|
-
children: modalTitle !== null && modalTitle !== void 0 ? modalTitle :
|
|
53854
|
+
children: modalTitle !== null && modalTitle !== void 0 ? modalTitle : 'Tambah Lokasi di Map'
|
|
53739
53855
|
}), jsx(ModalDialogContent, {
|
|
53740
53856
|
css: {
|
|
53741
53857
|
overflowY: 'auto',
|
|
@@ -53743,13 +53859,12 @@ function InputMapPicker(props) {
|
|
|
53743
53859
|
position: 'relative'
|
|
53744
53860
|
},
|
|
53745
53861
|
children: jsx(MapPicker, {
|
|
53746
|
-
showBanner: showBanner,
|
|
53747
|
-
bannerDescription: bannerDescription,
|
|
53748
53862
|
value: value,
|
|
53749
53863
|
onChange: handleChange,
|
|
53750
|
-
onMarkerClick: handleMarkerClick,
|
|
53751
53864
|
radius: radius,
|
|
53752
|
-
showSelectButton: showSelectButton
|
|
53865
|
+
showSelectButton: showSelectButton,
|
|
53866
|
+
readOnly: readOnly,
|
|
53867
|
+
header: header
|
|
53753
53868
|
})
|
|
53754
53869
|
})]
|
|
53755
53870
|
})]
|
|
@@ -57107,4 +57222,4 @@ const useToggle = initialValue => {
|
|
|
57107
57222
|
return useReducer(toggleReducer, initialValue);
|
|
57108
57223
|
};
|
|
57109
57224
|
|
|
57110
|
-
export { ADVANCE_PICKER, Accordion, AccordionContent, AccordionItem, AccordionTrigger, AdvancedOption, AlertDialog, AlertDialogCancel, AlertDialogConfirm, AlertDialogContent, AlertDialogDescription, AlertDialogFunction, AlertDialogRoot, AlertDialogTitle, AlertDialogTrigger, Avatar, BOTTOM_LEFT_POSITION, BOTTOM_RIGHT_POSITION, Badge, Banner, BannerClose, BannerDescription, BannerLink, BannerTitle, BarChartComponent as BarChart, Box, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Button$4 as Button, ButtonDropdown, ButtonGroup$1 as ButtonGroup, ButtonGroupItem, ButtonPrimitive, Card, CardComponent, CardLineColor, Cell, CheckboxGroup, CheckboxTable, ColorPicker_default as ColorPicker, Colors$1 as Colors, ContentEditor, ContextMenu, ContextMenuItem, ContextMenuSeparator, ContextMenuTrigger, CustomDatePicker, DATE_RANGE_PICKER, DEFAULT, DateColumn, DatePicker, DatePickerMulti, DecimalColumn, Device as DevicePreview, Dialog, DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerBody, DrawerClose, DrawerCloseButton, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuArrow, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuItemIndicator, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, EditableTable, Flex$1 as Flex, FormGroup, FormHelper, FormLabel, Grid, GridItem, Heading, IconButton, IconContainer, Image, ImageDevicePreview, Input$
|
|
57225
|
+
export { ADVANCE_PICKER, Accordion, AccordionContent, AccordionItem, AccordionTrigger, AdvancedOption, AlertDialog, AlertDialogCancel, AlertDialogConfirm, AlertDialogContent, AlertDialogDescription, AlertDialogFunction, AlertDialogRoot, AlertDialogTitle, AlertDialogTrigger, Avatar, BOTTOM_LEFT_POSITION, BOTTOM_RIGHT_POSITION, Badge, Banner, BannerClose, BannerDescription, BannerLink, BannerTitle, BarChartComponent as BarChart, Box, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Button$4 as Button, ButtonDropdown, ButtonGroup$1 as ButtonGroup, ButtonGroupItem, ButtonPrimitive, Card, CardComponent, CardLineColor, Cell, CheckboxGroup, CheckboxTable, ColorPicker_default as ColorPicker, Colors$1 as Colors, ContentEditor, ContextMenu, ContextMenuItem, ContextMenuSeparator, ContextMenuTrigger, CustomDatePicker, DATE_RANGE_PICKER, DEFAULT, DateColumn, DatePicker, DatePickerMulti, DecimalColumn, Device as DevicePreview, Dialog, DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerBody, DrawerClose, DrawerCloseButton, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuArrow, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuItemIndicator, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, EditableTable, Flex$1 as Flex, FormGroup, FormHelper, FormLabel, Grid, GridItem, Heading, IconButton, IconContainer, Image, ImageDevicePreview, Input$6 as Input, InputCheckbox, InputColorPicker, InputCombobox, InputCounter, InputCreatable, InputDatePicker, InputDateRange, InputGroup, InputLeftAddon, InputLeftElement, InputMapPicker, InputNumber, InputOTP, InputPrefix, InputRadio, InputRadioGroup, InputResourceList, InputRightAddon, InputRightElement, InputSearchbox, InputSelect, InputSelectCheck, InputSelectTag, InputSignature, InputSuffix, InputSwitch, InputSwitchWithImage, TagsInput as InputTags, InputText, InputTextArea, InputTimePicker, LAST_30_DAYS, LAST_7_DAYS, LAST_MONTH, LAST_TWO_MONTHS, LAST_WEEK, LineChart, Link, LoadingBar, MONTHLY, MajooProvider, MapPicker, MemoizedEditableTable, MobileTable, ModalDialog, ModalDialogContent, ModalDialogFooter, ModalDialogTitle, ModalDialogTrigger, NEXT_MONTH, NEXT_WEEK, NativeTimePicker, NotificationBadge, OptionWrapper$2 as OptionWrapper, PREV_MONTH, PREV_WEEK, PageContainer, PageDialog, PageDialogContent, PageDialogFooter, PageDialogTitle, PageDialogTrigger, Pagination, Paper, PaperComponent, Paragraph, PieChartComponent as PieChart, Popover, PopoverClose, PopoverContent, PopoverTrigger, PriceColumn, Progress$1 as Progress, ProgressIndicator, RANGE_CONTROL, RANGE_MONTH, RANGE_PICKER, RANGE_WEEK, ResendOTP, RightSlot, rowExpanderColumn as RowExpanderColumn, rowExpanderMultipleColumn as RowExpanderMultipleColumn, rowMenuColumn as RowMenuColumn, rowSelectionColumn as RowSelectionColumn, rowSelectionWithCallbackColumn as RowSelectionWithCallbackColumn, SINGLE_PICKER, ScrollSync, ScrollSyncNode, SelectBox, SelectContainer, SelectItem, SelectOption, Separator$2 as Separator, Skeleton, Slider, StepWizard, StepWizardContext, StyledBox, StyledDropdown, StyledInput$1 as StyledInput, StyledSpan, StyledTitle$2 as StyledTitle, THIS_MONTH, THIS_WEEK, TODAY, TOP_LEFT_POSITION, TOP_RIGHT_POSITION, Table, TableBody$3 as TableBody, TableCell$3 as TableCell, TableColumn, TableContent$3 as TableContent, TableFoot$2 as TableFoot, TableFootCell$2 as TableFootCell, TableFootRow$2 as TableFootRow, TableHead$3 as TableHead, TableHeadCellContent, TableHeaderCellContainer, TableOfContent, TableOfContentPage, TableRow$3 as TableRow, Tabs$1 as Tabs, TabsContent$1 as TabsContent, TabsList$1 as TabsList, TabsTrigger$1 as TabsTrigger, Tag, TagList, TagStatus, Text$1 as Text, TextVariantsEnum, TimePicker, ToastContext, ToastProvider, Tooltip$1 as Tooltip, UPDATE_PICKER, Upload, WEEKLY, YESTERDAY, addOnCellStyle, advancePickerDate, advancePickerOptionsEn, advancePickerOptionsId, defaultEmptyDataProps, defaultFetchDataParams, pickerReducer, useListOption, useToggle };
|