@multiplatform.one/forms 7.6.0 → 7.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/fields/FileUpload/index.cjs +55 -2
- package/dist/cjs/fields/FileUpload/index.native.js +65 -2
- package/dist/cjs/fields/FileUpload/index.native.js.map +1 -1
- package/dist/cjs/fields/Geolocation/geoValue.cjs +122 -0
- package/dist/cjs/fields/Geolocation/geoValue.native.js +151 -0
- package/dist/cjs/fields/Geolocation/geoValue.native.js.map +1 -0
- package/dist/cjs/fields/Geolocation/index.cjs +16 -29
- package/dist/cjs/fields/Geolocation/index.native.js +16 -29
- package/dist/cjs/fields/Geolocation/index.native.js.map +1 -1
- package/dist/esm/fields/FileUpload/index.mjs +55 -2
- package/dist/esm/fields/FileUpload/index.mjs.map +1 -1
- package/dist/esm/fields/FileUpload/index.native.js +65 -2
- package/dist/esm/fields/FileUpload/index.native.js.map +1 -1
- package/dist/esm/fields/Geolocation/geoValue.mjs +95 -0
- package/dist/esm/fields/Geolocation/geoValue.mjs.map +1 -0
- package/dist/esm/fields/Geolocation/geoValue.native.js +121 -0
- package/dist/esm/fields/Geolocation/geoValue.native.js.map +1 -0
- package/dist/esm/fields/Geolocation/index.mjs +15 -28
- package/dist/esm/fields/Geolocation/index.mjs.map +1 -1
- package/dist/esm/fields/Geolocation/index.native.js +15 -28
- package/dist/esm/fields/Geolocation/index.native.js.map +1 -1
- package/dist/jsx/AdaptivePopup/index.native.js +1 -1
- package/dist/jsx/AdaptivePopup/index.native.js.map +1 -1
- package/dist/jsx/Button/index.native.js +1 -1
- package/dist/jsx/Button/index.native.js.map +1 -1
- package/dist/jsx/Chip/index.native.js.map +1 -1
- package/dist/jsx/ContextualSaveBar/UnsavedChangesDialog.native.js +1 -1
- package/dist/jsx/ContextualSaveBar/UnsavedChangesDialog.native.js.map +1 -1
- package/dist/jsx/ContextualSaveBar/clientKnownIdentity.native.js.map +1 -1
- package/dist/jsx/ContextualSaveBar/commitImmediateField.native.js.map +1 -1
- package/dist/jsx/ContextualSaveBar/index.native.js +3 -3
- package/dist/jsx/ContextualSaveBar/index.native.js.map +1 -1
- package/dist/jsx/ContextualSaveBar/useUnsavedChangesGuard.native.js.map +1 -1
- package/dist/jsx/ControlGroup/index.native.js +1 -1
- package/dist/jsx/ControlGroup/index.native.js.map +1 -1
- package/dist/jsx/DescriptionList/index.native.js +2 -2
- package/dist/jsx/DescriptionList/index.native.js.map +1 -1
- package/dist/jsx/ErrorSummary.native.js.map +1 -1
- package/dist/jsx/FieldDisplay/editMode.native.js.map +1 -1
- package/dist/jsx/FieldDisplay/formatters.native.js.map +1 -1
- package/dist/jsx/FieldDisplay/index.native.js +1 -1
- package/dist/jsx/FieldDisplay/index.native.js.map +1 -1
- package/dist/jsx/FieldGroup.native.js.map +1 -1
- package/dist/jsx/FloatingPanel/useFloatingPanel.native.js.map +1 -1
- package/dist/jsx/Form/index.native.js +1 -1
- package/dist/jsx/Form/index.native.js.map +1 -1
- package/dist/jsx/Form/validateOn.native.js.map +1 -1
- package/dist/jsx/FormGrid.native.js.map +1 -1
- package/dist/jsx/FormSection.native.js.map +1 -1
- package/dist/jsx/InputParts/index.native.js.map +1 -1
- package/dist/jsx/Label/index.native.js.map +1 -1
- package/dist/jsx/Skeleton/index.native.js.map +1 -1
- package/dist/jsx/Spinner/SpinnerGlyph.native.js.map +1 -1
- package/dist/jsx/Spinner/spinnerSize.native.js.map +1 -1
- package/dist/jsx/Table/index.native.js.map +1 -1
- package/dist/jsx/Wheel/haptic.native.js.map +1 -1
- package/dist/jsx/Wheel/index.native.js.map +1 -1
- package/dist/jsx/actionLabel.native.js.map +1 -1
- package/dist/jsx/fieldDefaults.native.js.map +1 -1
- package/dist/jsx/fieldLayout.native.js +1 -1
- package/dist/jsx/fieldLayout.native.js.map +1 -1
- package/dist/jsx/fields/Barcode/BarcodePreview.native.js.map +1 -1
- package/dist/jsx/fields/Barcode/BarcodeScanner.native.js +1 -1
- package/dist/jsx/fields/Barcode/code128.native.js.map +1 -1
- package/dist/jsx/fields/Barcode/index.native.js +2 -2
- package/dist/jsx/fields/Barcode/index.native.js.map +1 -1
- package/dist/jsx/fields/Barcode/qr.native.js.map +1 -1
- package/dist/jsx/fields/Barcode/scannerTypes.native.js.map +1 -1
- package/dist/jsx/fields/Checkbox/Checkbox.native.js +1 -1
- package/dist/jsx/fields/Checkbox/Checkbox.native.js.map +1 -1
- package/dist/jsx/fields/Checkbox/CheckboxBox.native.js.map +1 -1
- package/dist/jsx/fields/Checkbox/CheckboxCard.native.js.map +1 -1
- package/dist/jsx/fields/Checkbox/CheckboxFieldFrame.native.js.map +1 -1
- package/dist/jsx/fields/Checkbox/CheckboxGroup.native.js +1 -1
- package/dist/jsx/fields/Checkbox/CheckboxGroup.native.js.map +1 -1
- package/dist/jsx/fields/Checkbox/index.native.js.map +1 -1
- package/dist/jsx/fields/ColorPicker/index.native.js +3 -3
- package/dist/jsx/fields/ColorPicker/index.native.js.map +1 -1
- package/dist/jsx/fields/ColorPicker/parts.native.js +2 -2
- package/dist/jsx/fields/ColorPicker/parts.native.js.map +1 -1
- package/dist/jsx/fields/Combobox/authorOptions.native.js.map +1 -1
- package/dist/jsx/fields/Combobox/index.native.js +5 -5
- package/dist/jsx/fields/Combobox/index.native.js.map +1 -1
- package/dist/jsx/fields/DatePicker/Calendar.native.js.map +1 -1
- package/dist/jsx/fields/DatePicker/DateRangePicker.native.js +2 -2
- package/dist/jsx/fields/DatePicker/DateRangePicker.native.js.map +1 -1
- package/dist/jsx/fields/DatePicker/DatetimePicker.native.js +3 -3
- package/dist/jsx/fields/DatePicker/DatetimePicker.native.js.map +1 -1
- package/dist/jsx/fields/DatePicker/MonthPicker.native.js +2 -2
- package/dist/jsx/fields/DatePicker/MonthPicker.native.js.map +1 -1
- package/dist/jsx/fields/DatePicker/MultiDatePicker.native.js +2 -2
- package/dist/jsx/fields/DatePicker/MultiDatePicker.native.js.map +1 -1
- package/dist/jsx/fields/DatePicker/fieldValueSync.native.js.map +1 -1
- package/dist/jsx/fields/DatePicker/index.native.js +2 -2
- package/dist/jsx/fields/DatePicker/index.native.js.map +1 -1
- package/dist/jsx/fields/DatePicker/parts.native.js +2 -2
- package/dist/jsx/fields/DatePicker/parts.native.js.map +1 -1
- package/dist/jsx/fields/DatePicker/utils.native.js.map +1 -1
- package/dist/jsx/fields/Duration/durationMath.native.js.map +1 -1
- package/dist/jsx/fields/Duration/index.native.js +3 -3
- package/dist/jsx/fields/Duration/index.native.js.map +1 -1
- package/dist/jsx/fields/FileUpload/filePickerTypes.native.js.map +1 -1
- package/dist/jsx/fields/FileUpload/index.mjs +55 -2
- package/dist/jsx/fields/FileUpload/index.mjs.map +1 -1
- package/dist/jsx/fields/FileUpload/index.native.js +67 -4
- package/dist/jsx/fields/FileUpload/index.native.js.map +1 -1
- package/dist/jsx/fields/FileUpload/nativePickerLoader.native.js.map +1 -1
- package/dist/jsx/fields/Geolocation/expoMapsLoader.native.js.map +1 -1
- package/dist/jsx/fields/Geolocation/geoValue.mjs +95 -0
- package/dist/jsx/fields/Geolocation/geoValue.mjs.map +1 -0
- package/dist/jsx/fields/Geolocation/geoValue.native.js +151 -0
- package/dist/jsx/fields/Geolocation/geoValue.native.js.map +1 -0
- package/dist/jsx/fields/Geolocation/index.mjs +15 -28
- package/dist/jsx/fields/Geolocation/index.mjs.map +1 -1
- package/dist/jsx/fields/Geolocation/index.native.js +21 -34
- package/dist/jsx/fields/Geolocation/index.native.js.map +1 -1
- package/dist/jsx/fields/Geolocation/mapMath.native.js.map +1 -1
- package/dist/jsx/fields/Geolocation/mapTypes.native.js.map +1 -1
- package/dist/jsx/fields/Icon/drawnSet.native.js.map +1 -1
- package/dist/jsx/fields/Icon/index.native.js +3 -3
- package/dist/jsx/fields/Icon/index.native.js.map +1 -1
- package/dist/jsx/fields/ImageField/index.native.js +2 -2
- package/dist/jsx/fields/ImageField/index.native.js.map +1 -1
- package/dist/jsx/fields/Input/index.native.js +2 -2
- package/dist/jsx/fields/Input/index.native.js.map +1 -1
- package/dist/jsx/fields/MentionInput/index.native.js +3 -3
- package/dist/jsx/fields/MentionInput/index.native.js.map +1 -1
- package/dist/jsx/fields/OTPInput/index.native.js +3 -3
- package/dist/jsx/fields/OTPInput/index.native.js.map +1 -1
- package/dist/jsx/fields/OTPInput/otpCellCss.native.js.map +1 -1
- package/dist/jsx/fields/PhoneInput/dialCodes.native.js.map +1 -1
- package/dist/jsx/fields/PhoneInput/index.native.js +3 -3
- package/dist/jsx/fields/PhoneInput/index.native.js.map +1 -1
- package/dist/jsx/fields/PhoneInput/phone.native.js.map +1 -1
- package/dist/jsx/fields/Progress/index.native.js +1 -1
- package/dist/jsx/fields/Progress/index.native.js.map +1 -1
- package/dist/jsx/fields/RadioGroup/index.native.js +1 -1
- package/dist/jsx/fields/RadioGroup/index.native.js.map +1 -1
- package/dist/jsx/fields/Rating/index.native.js +1 -1
- package/dist/jsx/fields/Rating/index.native.js.map +1 -1
- package/dist/jsx/fields/Rating/ratingMath.native.js.map +1 -1
- package/dist/jsx/fields/Rating/types.native.js.map +1 -1
- package/dist/jsx/fields/SearchInput/index.native.js +2 -2
- package/dist/jsx/fields/SearchInput/index.native.js.map +1 -1
- package/dist/jsx/fields/Select/index.native.js +4 -4
- package/dist/jsx/fields/Select/index.native.js.map +1 -1
- package/dist/jsx/fields/Signature/index.native.js +2 -2
- package/dist/jsx/fields/Signature/index.native.js.map +1 -1
- package/dist/jsx/fields/Slider/index.native.js +1 -1
- package/dist/jsx/fields/Slider/index.native.js.map +1 -1
- package/dist/jsx/fields/Slider/jumpMotion.native.js.map +1 -1
- package/dist/jsx/fields/Stepper/index.native.js +2 -2
- package/dist/jsx/fields/Stepper/index.native.js.map +1 -1
- package/dist/jsx/fields/Stepper/resolveStepperPlacement.native.js.map +1 -1
- package/dist/jsx/fields/Switch/index.native.js +2 -2
- package/dist/jsx/fields/Switch/index.native.js.map +1 -1
- package/dist/jsx/fields/TextArea/index.native.js +2 -2
- package/dist/jsx/fields/TextArea/index.native.js.map +1 -1
- package/dist/jsx/fields/TimePicker/index.native.js +3 -3
- package/dist/jsx/fields/TimePicker/index.native.js.map +1 -1
- package/dist/jsx/fields/TimePicker/parts.native.js +1 -1
- package/dist/jsx/fields/TimePicker/parts.native.js.map +1 -1
- package/dist/jsx/fields/TimeRangeScrubber/geometry.native.js.map +1 -1
- package/dist/jsx/fields/TimeRangeScrubber/index.native.js +2 -2
- package/dist/jsx/fields/TimeRangeScrubber/index.native.js.map +1 -1
- package/dist/jsx/fields/ToggleGroup/index.native.js +1 -1
- package/dist/jsx/fields/ToggleGroup/index.native.js.map +1 -1
- package/dist/jsx/fields/selectedOrder.native.js.map +1 -1
- package/dist/jsx/formSpacing.native.js.map +1 -1
- package/dist/jsx/hooks/useFocusManagement.native.js.map +1 -1
- package/dist/jsx/index.native.js +43 -43
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/requiredMarking.native.js.map +1 -1
- package/dist/jsx/shared/TimeColumn.native.js +1 -1
- package/dist/jsx/shared/TimeColumn.native.js.map +1 -1
- package/dist/jsx/shared/capabilityPreflight.native.js.map +1 -1
- package/dist/jsx/shared/colorRamps.native.js.map +1 -1
- package/dist/jsx/shared/devWarn.native.js.map +1 -1
- package/dist/jsx/shared/floatingList.native.js +1 -1
- package/dist/jsx/shared/floatingList.native.js.map +1 -1
- package/dist/jsx/shared/focusManagement.native.js.map +1 -1
- package/dist/jsx/shared/groupContext.native.js.map +1 -1
- package/dist/jsx/shared/i18n.native.js.map +1 -1
- package/dist/jsx/shared/t.native.js.map +1 -1
- package/dist/jsx/shared/tableCellContext.native.js.map +1 -1
- package/dist/jsx/shared/useDragScroll.native.js.map +1 -1
- package/dist/jsx/shared/useKeyboardInset.native.js.map +1 -1
- package/dist/jsx/shared/useSheetEscapeDismiss.native.js.map +1 -1
- package/dist/jsx/shared/useWheelIncrement.native.js.map +1 -1
- package/dist/jsx/shared/utils.native.js +1 -1
- package/dist/jsx/shared/utils.native.js.map +1 -1
- package/dist/jsx/shared/zIndex.native.js.map +1 -1
- package/dist/jsx/themedPrimitives.native.js.map +1 -1
- package/dist/jsx/types.native.js.map +1 -1
- package/dist/jsx/utils/LinkCell.native.js.map +1 -1
- package/package.json +7 -7
- package/src/Button/Button.stories.tsx +90 -1
- package/src/fields/Barcode/BarcodePreview.spec.tsx +14 -0
- package/src/fields/Barcode/BarcodePreview.stories.tsx +104 -0
- package/src/fields/ColorPicker/PresetSwatches.spec.tsx +71 -0
- package/src/fields/ColorPicker/PresetSwatches.stories.tsx +94 -0
- package/src/fields/FileUpload/FileUpload.spec.tsx +43 -0
- package/src/fields/FileUpload/index.tsx +74 -2
- package/src/fields/Geolocation/Geolocation.spec.tsx +126 -0
- package/src/fields/Geolocation/geoValue.spec.ts +169 -0
- package/src/fields/Geolocation/geoValue.ts +149 -0
- package/src/fields/Geolocation/index.tsx +15 -24
- package/types/fields/FileUpload/index.d.ts.map +1 -1
- package/types/fields/Geolocation/geoValue.d.ts +45 -0
- package/types/fields/Geolocation/geoValue.d.ts.map +1 -0
- package/types/fields/Geolocation/index.d.ts.map +1 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var geoValue_exports = {};
|
|
24
|
+
__export(geoValue_exports, {
|
|
25
|
+
detectGeoShape: () => detectGeoShape,
|
|
26
|
+
formatGeoValue: () => formatGeoValue,
|
|
27
|
+
parseGeoValue: () => parseGeoValue
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(geoValue_exports);
|
|
30
|
+
function isFiniteNumber(n) {
|
|
31
|
+
return typeof n === "number" && Number.isFinite(n);
|
|
32
|
+
}
|
|
33
|
+
function parseJson(value) {
|
|
34
|
+
if (!value || !value.trim()) return null;
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(value);
|
|
37
|
+
} catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function firstPoint(parsed) {
|
|
42
|
+
if (!parsed || typeof parsed !== "object") return null;
|
|
43
|
+
const collection = parsed;
|
|
44
|
+
if (collection.type !== "FeatureCollection" || !Array.isArray(collection.features)) return null;
|
|
45
|
+
for (const feature of collection.features) {
|
|
46
|
+
if (!feature || typeof feature !== "object") continue;
|
|
47
|
+
const geometry = feature.geometry;
|
|
48
|
+
if (!geometry || geometry.type !== "Point") continue;
|
|
49
|
+
const coordinates = geometry.coordinates;
|
|
50
|
+
if (!Array.isArray(coordinates) || coordinates.length < 2) continue;
|
|
51
|
+
const [lng, lat] = coordinates;
|
|
52
|
+
if (!isFiniteNumber(lng) || !isFiniteNumber(lat)) continue;
|
|
53
|
+
return {
|
|
54
|
+
type: "Point",
|
|
55
|
+
coordinates: [lng, lat]
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
function parseGeoValue(value) {
|
|
61
|
+
const parsed = parseJson(value);
|
|
62
|
+
if (!parsed || typeof parsed !== "object") return null;
|
|
63
|
+
const native = parsed;
|
|
64
|
+
if (isFiniteNumber(native.lat) && isFiniteNumber(native.lng)) {
|
|
65
|
+
return {
|
|
66
|
+
lat: native.lat,
|
|
67
|
+
lng: native.lng
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const point = firstPoint(parsed);
|
|
71
|
+
if (point) {
|
|
72
|
+
const [lng, lat] = point.coordinates;
|
|
73
|
+
return {
|
|
74
|
+
lat,
|
|
75
|
+
lng
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
function detectGeoShape(value) {
|
|
81
|
+
const parsed = parseJson(value);
|
|
82
|
+
if (!parsed || typeof parsed !== "object") return "latlng";
|
|
83
|
+
if (parsed.type === "FeatureCollection") return "featurecollection";
|
|
84
|
+
return "latlng";
|
|
85
|
+
}
|
|
86
|
+
function asFeatures(parsed) {
|
|
87
|
+
if (!parsed || typeof parsed !== "object") return [];
|
|
88
|
+
const collection = parsed;
|
|
89
|
+
if (collection.type !== "FeatureCollection" || !Array.isArray(collection.features)) return [];
|
|
90
|
+
return collection.features.filter(feature => !!feature && typeof feature === "object");
|
|
91
|
+
}
|
|
92
|
+
function isPointFeature(feature) {
|
|
93
|
+
return !!feature.geometry && feature.geometry.type === "Point";
|
|
94
|
+
}
|
|
95
|
+
function formatGeoValue(coordinates, shape, previous) {
|
|
96
|
+
if (shape !== "featurecollection") return JSON.stringify(coordinates);
|
|
97
|
+
const point = {
|
|
98
|
+
type: "Point",
|
|
99
|
+
coordinates: [coordinates.lng, coordinates.lat]
|
|
100
|
+
};
|
|
101
|
+
const existing = asFeatures(parseJson(previous));
|
|
102
|
+
let moved = false;
|
|
103
|
+
const features = existing.map(feature => {
|
|
104
|
+
if (moved || !isPointFeature(feature)) return feature;
|
|
105
|
+
moved = true;
|
|
106
|
+
return {
|
|
107
|
+
...feature,
|
|
108
|
+
geometry: point
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
if (!moved) {
|
|
112
|
+
features.push({
|
|
113
|
+
type: "Feature",
|
|
114
|
+
properties: {},
|
|
115
|
+
geometry: point
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return JSON.stringify({
|
|
119
|
+
type: "FeatureCollection",
|
|
120
|
+
features
|
|
121
|
+
});
|
|
122
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var geoValue_exports = {};
|
|
26
|
+
__export(geoValue_exports, {
|
|
27
|
+
detectGeoShape: () => detectGeoShape,
|
|
28
|
+
formatGeoValue: () => formatGeoValue,
|
|
29
|
+
parseGeoValue: () => parseGeoValue
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(geoValue_exports);
|
|
32
|
+
function _type_of(obj) {
|
|
33
|
+
"@swc/helpers - typeof";
|
|
34
|
+
|
|
35
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
36
|
+
}
|
|
37
|
+
function isFiniteNumber(n) {
|
|
38
|
+
return typeof n === "number" && Number.isFinite(n);
|
|
39
|
+
}
|
|
40
|
+
function parseJson(value) {
|
|
41
|
+
if (!value || !value.trim()) return null;
|
|
42
|
+
try {
|
|
43
|
+
return JSON.parse(value);
|
|
44
|
+
} catch (unused) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function firstPoint(parsed) {
|
|
49
|
+
if (!parsed || (typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) !== "object") return null;
|
|
50
|
+
var collection = parsed;
|
|
51
|
+
if (collection.type !== "FeatureCollection" || !Array.isArray(collection.features)) return null;
|
|
52
|
+
var _iteratorNormalCompletion = true,
|
|
53
|
+
_didIteratorError = false,
|
|
54
|
+
_iteratorError = void 0;
|
|
55
|
+
try {
|
|
56
|
+
for (var _iterator = collection.features[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
57
|
+
var feature = _step.value;
|
|
58
|
+
if (!feature || (typeof feature === "undefined" ? "undefined" : _type_of(feature)) !== "object") continue;
|
|
59
|
+
var geometry = feature.geometry;
|
|
60
|
+
if (!geometry || geometry.type !== "Point") continue;
|
|
61
|
+
var coordinates = geometry.coordinates;
|
|
62
|
+
if (!Array.isArray(coordinates) || coordinates.length < 2) continue;
|
|
63
|
+
var [lng, lat] = coordinates;
|
|
64
|
+
if (!isFiniteNumber(lng) || !isFiniteNumber(lat)) continue;
|
|
65
|
+
return {
|
|
66
|
+
type: "Point",
|
|
67
|
+
coordinates: [lng, lat]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
} catch (err) {
|
|
71
|
+
_didIteratorError = true;
|
|
72
|
+
_iteratorError = err;
|
|
73
|
+
} finally {
|
|
74
|
+
try {
|
|
75
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
76
|
+
_iterator.return();
|
|
77
|
+
}
|
|
78
|
+
} finally {
|
|
79
|
+
if (_didIteratorError) {
|
|
80
|
+
throw _iteratorError;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
function parseGeoValue(value) {
|
|
87
|
+
var parsed = parseJson(value);
|
|
88
|
+
if (!parsed || (typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) !== "object") return null;
|
|
89
|
+
var native = parsed;
|
|
90
|
+
if (isFiniteNumber(native.lat) && isFiniteNumber(native.lng)) {
|
|
91
|
+
return {
|
|
92
|
+
lat: native.lat,
|
|
93
|
+
lng: native.lng
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
var point = firstPoint(parsed);
|
|
97
|
+
if (point) {
|
|
98
|
+
var [lng, lat] = point.coordinates;
|
|
99
|
+
return {
|
|
100
|
+
lat,
|
|
101
|
+
lng
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
function detectGeoShape(value) {
|
|
107
|
+
var parsed = parseJson(value);
|
|
108
|
+
if (!parsed || (typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) !== "object") return "latlng";
|
|
109
|
+
if (parsed.type === "FeatureCollection") return "featurecollection";
|
|
110
|
+
return "latlng";
|
|
111
|
+
}
|
|
112
|
+
function asFeatures(parsed) {
|
|
113
|
+
if (!parsed || (typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) !== "object") return [];
|
|
114
|
+
var collection = parsed;
|
|
115
|
+
if (collection.type !== "FeatureCollection" || !Array.isArray(collection.features)) return [];
|
|
116
|
+
return collection.features.filter(function (feature) {
|
|
117
|
+
return !!feature && (typeof feature === "undefined" ? "undefined" : _type_of(feature)) === "object";
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function isPointFeature(feature) {
|
|
121
|
+
return !!feature.geometry && feature.geometry.type === "Point";
|
|
122
|
+
}
|
|
123
|
+
function formatGeoValue(coordinates, shape, previous) {
|
|
124
|
+
if (shape !== "featurecollection") return JSON.stringify(coordinates);
|
|
125
|
+
var point = {
|
|
126
|
+
type: "Point",
|
|
127
|
+
coordinates: [coordinates.lng, coordinates.lat]
|
|
128
|
+
};
|
|
129
|
+
var existing = asFeatures(parseJson(previous));
|
|
130
|
+
var moved = false;
|
|
131
|
+
var features = existing.map(function (feature) {
|
|
132
|
+
if (moved || !isPointFeature(feature)) return feature;
|
|
133
|
+
moved = true;
|
|
134
|
+
return {
|
|
135
|
+
...feature,
|
|
136
|
+
geometry: point
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
if (!moved) {
|
|
140
|
+
features.push({
|
|
141
|
+
type: "Feature",
|
|
142
|
+
properties: {},
|
|
143
|
+
geometry: point
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return JSON.stringify({
|
|
147
|
+
type: "FeatureCollection",
|
|
148
|
+
features
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=geoValue.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","geoValue_exports","detectGeoShape","formatGeoValue","parseGeoValue","module","exports","_type_of","obj","Symbol","constructor","isFiniteNumber","n","Number","isFinite","parseJson","trim","JSON","parse","unused","firstPoint","parsed","collection","type","Array","isArray","features","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","iterator","_step","next","done","feature","geometry","coordinates","length","lng","lat","err","return","native","point","asFeatures","filter","isPointFeature","shape","previous","stringify","existing","moved","map","push","properties"],"sources":["geoValue.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar geoValue_exports = {};\n__export(geoValue_exports, {\n detectGeoShape: () => detectGeoShape,\n formatGeoValue: () => formatGeoValue,\n parseGeoValue: () => parseGeoValue\n});\nmodule.exports = __toCommonJS(geoValue_exports);\nfunction _type_of(obj) {\n \"@swc/helpers - typeof\";\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\nfunction isFiniteNumber(n) {\n return typeof n === \"number\" && Number.isFinite(n);\n}\nfunction parseJson(value) {\n if (!value || !value.trim()) return null;\n try {\n return JSON.parse(value);\n } catch (unused) {\n return null;\n }\n}\nfunction firstPoint(parsed) {\n if (!parsed || (typeof parsed === \"undefined\" ? \"undefined\" : _type_of(parsed)) !== \"object\") return null;\n var collection = parsed;\n if (collection.type !== \"FeatureCollection\" || !Array.isArray(collection.features)) return null;\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = collection.features[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var feature = _step.value;\n if (!feature || (typeof feature === \"undefined\" ? \"undefined\" : _type_of(feature)) !== \"object\") continue;\n var geometry = feature.geometry;\n if (!geometry || geometry.type !== \"Point\") continue;\n var coordinates = geometry.coordinates;\n if (!Array.isArray(coordinates) || coordinates.length < 2) continue;\n var [lng, lat] = coordinates;\n if (!isFiniteNumber(lng) || !isFiniteNumber(lat)) continue;\n return {\n type: \"Point\",\n coordinates: [\n lng,\n lat\n ]\n };\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return null;\n}\nfunction parseGeoValue(value) {\n var parsed = parseJson(value);\n if (!parsed || (typeof parsed === \"undefined\" ? \"undefined\" : _type_of(parsed)) !== \"object\") return null;\n var native = parsed;\n if (isFiniteNumber(native.lat) && isFiniteNumber(native.lng)) {\n return {\n lat: native.lat,\n lng: native.lng\n };\n }\n var point = firstPoint(parsed);\n if (point) {\n var [lng, lat] = point.coordinates;\n return {\n lat,\n lng\n };\n }\n return null;\n}\nfunction detectGeoShape(value) {\n var parsed = parseJson(value);\n if (!parsed || (typeof parsed === \"undefined\" ? \"undefined\" : _type_of(parsed)) !== \"object\") return \"latlng\";\n if (parsed.type === \"FeatureCollection\") return \"featurecollection\";\n return \"latlng\";\n}\nfunction asFeatures(parsed) {\n if (!parsed || (typeof parsed === \"undefined\" ? \"undefined\" : _type_of(parsed)) !== \"object\") return [];\n var collection = parsed;\n if (collection.type !== \"FeatureCollection\" || !Array.isArray(collection.features)) return [];\n return collection.features.filter(function(feature) {\n return !!feature && (typeof feature === \"undefined\" ? \"undefined\" : _type_of(feature)) === \"object\";\n });\n}\nfunction isPointFeature(feature) {\n return !!feature.geometry && feature.geometry.type === \"Point\";\n}\nfunction formatGeoValue(coordinates, shape, previous) {\n if (shape !== \"featurecollection\") return JSON.stringify(coordinates);\n var point = {\n type: \"Point\",\n coordinates: [\n coordinates.lng,\n coordinates.lat\n ]\n };\n var existing = asFeatures(parseJson(previous));\n var moved = false;\n var features = existing.map(function(feature) {\n if (moved || !isPointFeature(feature)) return feature;\n moved = true;\n return {\n ...feature,\n geometry: point\n };\n });\n if (!moved) {\n features.push({\n type: \"Feature\",\n properties: {},\n geometry: point\n });\n }\n return JSON.stringify({\n type: \"FeatureCollection\",\n features\n });\n}\n//# sourceMappingURL=geoValue.js.map\n"],"mappings":"AAAA,YAAY;;AACZ,IAAIA,SAAS,GAAGC,MAAM,CAACC,cAAc;AACrC,IAAIC,gBAAgB,GAAGF,MAAM,CAACG,wBAAwB;AACtD,IAAIC,iBAAiB,GAAGJ,MAAM,CAACK,mBAAmB;AAClD,IAAIC,YAAY,GAAGN,MAAM,CAACO,SAAS,CAACC,cAAc;AAClD,IAAIC,QAAQ,GAAGA,CAACC,MAAM,EAAEC,GAAG,KAAK;EAC9B,KAAK,IAAIC,IAAI,IAAID,GAAG,EAClBZ,SAAS,CAACW,MAAM,EAAEE,IAAI,EAAE;IAAEC,GAAG,EAAEF,GAAG,CAACC,IAAI,CAAC;IAAEE,UAAU,EAAE;EAAK,CAAC,CAAC;AACjE,CAAC;AACD,IAAIC,WAAW,GAAGA,CAACC,EAAE,EAAEC,IAAI,EAAEC,MAAM,EAAEC,IAAI,KAAK;EAC5C,IAAIF,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,IAAI,OAAOA,IAAI,KAAK,UAAU,EAAE;IAClE,KAAK,IAAIG,GAAG,IAAIhB,iBAAiB,CAACa,IAAI,CAAC,EACrC,IAAI,CAACX,YAAY,CAACe,IAAI,CAACL,EAAE,EAAEI,GAAG,CAAC,IAAIA,GAAG,KAAKF,MAAM,EAC/CnB,SAAS,CAACiB,EAAE,EAAEI,GAAG,EAAE;MAAEP,GAAG,EAAEA,CAAA,KAAMI,IAAI,CAACG,GAAG,CAAC;MAAEN,UAAU,EAAE,EAAEK,IAAI,GAAGjB,gBAAgB,CAACe,IAAI,EAAEG,GAAG,CAAC,CAAC,IAAID,IAAI,CAACL;IAAW,CAAC,CAAC;EACxH;EACA,OAAOE,EAAE;AACX,CAAC;AACD,IAAIM,YAA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O;MACL,GAAGjB,OAAO;MACVC,QAAQ,EAAEQ;IACZ,CAAC;EACH,CAAC,CAAC;EACF,IAAI,CAACQ,KAAK,EAAE;IACV1B,QAAQ,CAAC4B,IAAI,CAAC;MACZ/B,IAAI,EAAE,SAAS;MACfgC,UAAU,EAAE,CAAC,CAAC;MACdnB,QAAQ,EAAEQ;IACZ,CAAC,CAAC;EACJ;EACA,OAAO3B,IAAI,CAACiC,SAAS,CAAC;IACpB3B,IAAI,EAAE,mBAAmB;IACzBG;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -35,6 +35,7 @@ var import_Button = require("../../Button/index.cjs");
|
|
|
35
35
|
var import_fieldLayout = require("../../fieldLayout.cjs");
|
|
36
36
|
var import_FloatingPanel = require("../../FloatingPanel/index.cjs");
|
|
37
37
|
var import_GeolocationMap = require("./GeolocationMap.cjs");
|
|
38
|
+
var import_geoValue = require("./geoValue.cjs");
|
|
38
39
|
var import_InputParts = require("../../InputParts/index.cjs");
|
|
39
40
|
var import_Skeleton = require("../../Skeleton/index.cjs");
|
|
40
41
|
var import_capabilityPreflight = require("../../shared/capabilityPreflight.cjs");
|
|
@@ -74,20 +75,6 @@ function mapGeolocationError(err) {
|
|
|
74
75
|
}
|
|
75
76
|
return err.message || (0, import_t.t)("Failed to get location");
|
|
76
77
|
}
|
|
77
|
-
function parseGeoValue(value) {
|
|
78
|
-
if (!value || !value.trim()) return null;
|
|
79
|
-
try {
|
|
80
|
-
const parsed = JSON.parse(value);
|
|
81
|
-
if (typeof parsed.lat !== "number" || typeof parsed.lng !== "number") return null;
|
|
82
|
-
if (!Number.isFinite(parsed.lat) || !Number.isFinite(parsed.lng)) return null;
|
|
83
|
-
return {
|
|
84
|
-
lat: parsed.lat,
|
|
85
|
-
lng: parsed.lng
|
|
86
|
-
};
|
|
87
|
-
} catch {
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
78
|
function clampLat(val) {
|
|
92
79
|
return Math.max(-90, Math.min(90, val));
|
|
93
80
|
}
|
|
@@ -521,6 +508,7 @@ function Geolocation({
|
|
|
521
508
|
const [preflightError, setPreflightError] = (0, import_react2.useState)();
|
|
522
509
|
const preflightingRef = (0, import_react2.useRef)(false);
|
|
523
510
|
const onValueChangeRef = (0, import_react2.useRef)(() => {});
|
|
511
|
+
const currentValueRef = (0, import_react2.useRef)("");
|
|
524
512
|
const requestPosition = (0, import_react2.useCallback)(() => {
|
|
525
513
|
if (!navigator?.geolocation) {
|
|
526
514
|
setLocateError((0, import_t.t)("Geolocation unavailable: not supported in this browser."));
|
|
@@ -532,10 +520,11 @@ function Geolocation({
|
|
|
532
520
|
navigator.geolocation.getCurrentPosition(position => {
|
|
533
521
|
const lat = clampLat(position.coords.latitude);
|
|
534
522
|
const lng = clampLng(position.coords.longitude);
|
|
535
|
-
|
|
523
|
+
const previous = currentValueRef.current;
|
|
524
|
+
onValueChangeRef.current((0, import_geoValue.formatGeoValue)({
|
|
536
525
|
lat,
|
|
537
526
|
lng
|
|
538
|
-
}));
|
|
527
|
+
}, (0, import_geoValue.detectGeoShape)(previous), previous));
|
|
539
528
|
setLocatePhase("idle");
|
|
540
529
|
setLocateError(null);
|
|
541
530
|
}, err => {
|
|
@@ -566,21 +555,19 @@ function Geolocation({
|
|
|
566
555
|
}, [disabled, readOnly, locatePhase, requestPosition]);
|
|
567
556
|
const makeHandlers = (0, import_react2.useCallback)((currentValue, onValueChange) => {
|
|
568
557
|
onValueChangeRef.current = onValueChange;
|
|
569
|
-
|
|
558
|
+
currentValueRef.current = currentValue;
|
|
559
|
+
const coordinates = (0, import_geoValue.parseGeoValue)(currentValue);
|
|
560
|
+
const shape = (0, import_geoValue.detectGeoShape)(currentValue);
|
|
561
|
+
const write = (lat, lng) => {
|
|
562
|
+
onValueChange((0, import_geoValue.formatGeoValue)({
|
|
563
|
+
lat: clampLat(lat),
|
|
564
|
+
lng: clampLng(lng)
|
|
565
|
+
}, shape, currentValue));
|
|
566
|
+
};
|
|
570
567
|
return {
|
|
571
568
|
coordinates,
|
|
572
|
-
onCommitCoordinates:
|
|
573
|
-
|
|
574
|
-
lat: clampLat(lat),
|
|
575
|
-
lng: clampLng(lng)
|
|
576
|
-
}));
|
|
577
|
-
},
|
|
578
|
-
onMapChange: (lat, lng) => {
|
|
579
|
-
onValueChange(JSON.stringify({
|
|
580
|
-
lat: clampLat(lat),
|
|
581
|
-
lng: clampLng(lng)
|
|
582
|
-
}));
|
|
583
|
-
},
|
|
569
|
+
onCommitCoordinates: write,
|
|
570
|
+
onMapChange: write,
|
|
584
571
|
onUseMyLocation: () => {
|
|
585
572
|
void startLocate();
|
|
586
573
|
},
|
|
@@ -38,6 +38,7 @@ var import_Button = require("../../Button");
|
|
|
38
38
|
var import_fieldLayout = require("../../fieldLayout.native.js");
|
|
39
39
|
var import_FloatingPanel = require("../../FloatingPanel");
|
|
40
40
|
var import_GeolocationMap = require("./GeolocationMap.native.js");
|
|
41
|
+
var import_geoValue = require("./geoValue.native.js");
|
|
41
42
|
var import_InputParts = require("../../InputParts");
|
|
42
43
|
var import_Skeleton = require("../../Skeleton");
|
|
43
44
|
var import_capabilityPreflight = require("../../shared/capabilityPreflight.native.js");
|
|
@@ -76,20 +77,6 @@ function mapGeolocationError(err) {
|
|
|
76
77
|
}
|
|
77
78
|
return err.message || (0, import_t.t)("Failed to get location");
|
|
78
79
|
}
|
|
79
|
-
function parseGeoValue(value) {
|
|
80
|
-
if (!value || !value.trim()) return null;
|
|
81
|
-
try {
|
|
82
|
-
var parsed = JSON.parse(value);
|
|
83
|
-
if (typeof parsed.lat !== "number" || typeof parsed.lng !== "number") return null;
|
|
84
|
-
if (!Number.isFinite(parsed.lat) || !Number.isFinite(parsed.lng)) return null;
|
|
85
|
-
return {
|
|
86
|
-
lat: parsed.lat,
|
|
87
|
-
lng: parsed.lng
|
|
88
|
-
};
|
|
89
|
-
} catch (unused) {
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
80
|
function clampLat(val) {
|
|
94
81
|
return Math.max(-90, Math.min(90, val));
|
|
95
82
|
}
|
|
@@ -540,6 +527,7 @@ function Geolocation(param) {
|
|
|
540
527
|
var [preflightError, setPreflightError] = (0, import_react2.useState)();
|
|
541
528
|
var preflightingRef = (0, import_react2.useRef)(false);
|
|
542
529
|
var onValueChangeRef = (0, import_react2.useRef)(function () {});
|
|
530
|
+
var currentValueRef = (0, import_react2.useRef)("");
|
|
543
531
|
var requestPosition = (0, import_react2.useCallback)(function () {
|
|
544
532
|
var _navigator;
|
|
545
533
|
if (!((_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.geolocation)) {
|
|
@@ -552,10 +540,11 @@ function Geolocation(param) {
|
|
|
552
540
|
navigator.geolocation.getCurrentPosition(function (position) {
|
|
553
541
|
var lat = clampLat(position.coords.latitude);
|
|
554
542
|
var lng = clampLng(position.coords.longitude);
|
|
555
|
-
|
|
543
|
+
var previous = currentValueRef.current;
|
|
544
|
+
onValueChangeRef.current((0, import_geoValue.formatGeoValue)({
|
|
556
545
|
lat,
|
|
557
546
|
lng
|
|
558
|
-
}));
|
|
547
|
+
}, (0, import_geoValue.detectGeoShape)(previous), previous));
|
|
559
548
|
setLocatePhase("idle");
|
|
560
549
|
setLocateError(null);
|
|
561
550
|
}, function (err) {
|
|
@@ -586,21 +575,19 @@ function Geolocation(param) {
|
|
|
586
575
|
}, [disabled, readOnly, locatePhase, requestPosition]);
|
|
587
576
|
var makeHandlers = (0, import_react2.useCallback)(function (currentValue, onValueChange) {
|
|
588
577
|
onValueChangeRef.current = onValueChange;
|
|
589
|
-
|
|
578
|
+
currentValueRef.current = currentValue;
|
|
579
|
+
var coordinates = (0, import_geoValue.parseGeoValue)(currentValue);
|
|
580
|
+
var shape = (0, import_geoValue.detectGeoShape)(currentValue);
|
|
581
|
+
var write = function write2(lat, lng) {
|
|
582
|
+
onValueChange((0, import_geoValue.formatGeoValue)({
|
|
583
|
+
lat: clampLat(lat),
|
|
584
|
+
lng: clampLng(lng)
|
|
585
|
+
}, shape, currentValue));
|
|
586
|
+
};
|
|
590
587
|
return {
|
|
591
588
|
coordinates,
|
|
592
|
-
onCommitCoordinates:
|
|
593
|
-
|
|
594
|
-
lat: clampLat(lat),
|
|
595
|
-
lng: clampLng(lng)
|
|
596
|
-
}));
|
|
597
|
-
},
|
|
598
|
-
onMapChange: function onMapChange(lat, lng) {
|
|
599
|
-
onValueChange(JSON.stringify({
|
|
600
|
-
lat: clampLat(lat),
|
|
601
|
-
lng: clampLng(lng)
|
|
602
|
-
}));
|
|
603
|
-
},
|
|
589
|
+
onCommitCoordinates: write,
|
|
590
|
+
onMapChange: write,
|
|
604
591
|
onUseMyLocation: function onUseMyLocation() {
|
|
605
592
|
void startLocate();
|
|
606
593
|
},
|