@sanity/google-maps-input 5.0.2 → 6.0.0
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/README.md +17 -35
- package/dist/index.d.ts +17 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +436 -856
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# @sanity/google-maps-input
|
|
2
2
|
|
|
3
|
-
> For the v2 version, please refer to the [v2-branch](https://github.com/sanity-io/google-maps-input/tree/studio-v2).
|
|
4
|
-
|
|
5
3
|
## What is it?
|
|
6
4
|
|
|
7
5
|
Plugin for [Sanity Studio](https://www.sanity.io) providing input handlers for geo-related input types using Google Maps.
|
|
@@ -10,12 +8,6 @@ This plugin will replace the default `geopoint` input component and adds support
|
|
|
10
8
|
|
|
11
9
|

|
|
12
10
|
|
|
13
|
-
## Known issues in Studio V3
|
|
14
|
-
|
|
15
|
-
- Diff-preview is not implemented.
|
|
16
|
-
|
|
17
|
-
These will be re-added well before Studio V3 GA.
|
|
18
|
-
|
|
19
11
|
## Installation
|
|
20
12
|
|
|
21
13
|
In your studio folder, run:
|
|
@@ -24,12 +16,6 @@ In your studio folder, run:
|
|
|
24
16
|
npm install --save @sanity/google-maps-input
|
|
25
17
|
```
|
|
26
18
|
|
|
27
|
-
or
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
yarn add @sanity/google-maps-input
|
|
31
|
-
```
|
|
32
|
-
|
|
33
19
|
## Usage
|
|
34
20
|
|
|
35
21
|
Add it as a plugin in sanity.config.ts (or .js), with a valid [Google Maps API key](https://developers.google.com/maps/documentation/javascript/get-api-key):
|
|
@@ -53,10 +39,10 @@ export default defineConfig({
|
|
|
53
39
|
Ensure that the key has access to:
|
|
54
40
|
|
|
55
41
|
- Google Maps JavaScript API (for the interactive map)
|
|
56
|
-
- Google Places API Web Service (for the search feature)
|
|
57
42
|
- Google Static Maps API (for previewing a location)
|
|
43
|
+
- Google Places API (New) (for the search feature)
|
|
58
44
|
|
|
59
|
-
And that the key allows web-access from the Studio URL(s) you are using the plugin in.
|
|
45
|
+
And that the key allows web-access from the Studio URL(s) you are using the plugin in. If the key is missing or rejected, the input renders an inline message explaining what to fix.
|
|
60
46
|
|
|
61
47
|
### Configuration Options
|
|
62
48
|
|
|
@@ -113,29 +99,25 @@ The `geopointRadius` field type extends the basic geopoint with:
|
|
|
113
99
|
- Visual circle overlay on the map
|
|
114
100
|
- Editable radius input field
|
|
115
101
|
- Draggable circle for radius adjustment
|
|
116
|
-
- Enhanced diff visualization showing radius changes
|
|
117
|
-
|
|
118
|
-
## Stuck? Get help
|
|
119
|
-
|
|
120
|
-
[](https://slack.sanity.io/)
|
|
121
|
-
|
|
122
|
-
Join [Sanity’s developer community](https://slack.sanity.io) or ping us [on twitter](https://twitter.com/sanity_io).
|
|
123
|
-
|
|
124
|
-
## License
|
|
125
102
|
|
|
126
|
-
|
|
103
|
+
### Reviewing changes
|
|
127
104
|
|
|
128
|
-
|
|
105
|
+
In the document's **Review changes** pane, `geopoint` and `geopointRadius` values render as a before/after static map preview, matching the look of the built-in image diff.
|
|
129
106
|
|
|
130
|
-
|
|
107
|
+
`geopointRadius` fields get this automatically. Because `geopoint` is a built-in Sanity type, attach the exported `GeopointDiff` component to your `geopoint` fields to opt in:
|
|
131
108
|
|
|
132
|
-
|
|
133
|
-
|
|
109
|
+
```typescript
|
|
110
|
+
import {GeopointDiff} from '@sanity/google-maps-input'
|
|
134
111
|
|
|
135
|
-
|
|
136
|
-
|
|
112
|
+
// In your schema
|
|
113
|
+
export default {
|
|
114
|
+
name: 'location',
|
|
115
|
+
title: 'Location',
|
|
116
|
+
type: 'geopoint',
|
|
117
|
+
components: {diff: GeopointDiff},
|
|
118
|
+
}
|
|
119
|
+
```
|
|
137
120
|
|
|
138
|
-
|
|
121
|
+
## License
|
|
139
122
|
|
|
140
|
-
|
|
141
|
-
Make sure to select the main branch and check "Release new version".
|
|
123
|
+
MIT-licensed. See LICENSE.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { DiffProps, ObjectDiff, ObjectInputProps, ObjectSchemaType } from "sanity";
|
|
2
|
+
/**
|
|
3
|
+
* Diff component for `geopoint` and `geopointRadius` values. Renders a
|
|
4
|
+
* before/after static map preview using `DiffFromTo`, matching the look of the
|
|
5
|
+
* built-in image diff. Handles both types: the preview detects a `radius` field
|
|
6
|
+
* and draws the radius circle when present.
|
|
7
|
+
*/
|
|
8
|
+
declare function GeopointDiff({
|
|
9
|
+
diff,
|
|
10
|
+
schemaType
|
|
11
|
+
}: DiffProps<ObjectDiff>): import("react").JSX.Element;
|
|
3
12
|
interface LatLng {
|
|
4
13
|
lat: number;
|
|
5
14
|
lng: number;
|
|
@@ -19,12 +28,8 @@ interface GeopointRadius {
|
|
|
19
28
|
alt?: number;
|
|
20
29
|
radius: number;
|
|
21
30
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
interface GeopointRadiusSchemaType extends ObjectSchemaType {
|
|
26
|
-
diffComponent?: DiffComponent<ObjectDiff<GeopointRadius>> | DiffComponentOptions<ObjectDiff<GeopointRadius>>;
|
|
27
|
-
}
|
|
31
|
+
type GeopointSchemaType = ObjectSchemaType;
|
|
32
|
+
type GeopointRadiusSchemaType = ObjectSchemaType;
|
|
28
33
|
interface GoogleMapsInputConfig {
|
|
29
34
|
apiKey: string;
|
|
30
35
|
defaultZoom?: number;
|
|
@@ -36,20 +41,14 @@ interface GoogleMapsInputConfig {
|
|
|
36
41
|
defaultRadiusZoom?: number;
|
|
37
42
|
defaultRadius?: number;
|
|
38
43
|
}
|
|
39
|
-
type GeopointInputProps = ObjectInputProps<Geopoint
|
|
44
|
+
type GeopointInputProps = ObjectInputProps<Geopoint> & {
|
|
40
45
|
geoConfig: GoogleMapsInputConfig;
|
|
41
46
|
};
|
|
42
47
|
declare function GeopointInput(props: GeopointInputProps): import("react").JSX.Element;
|
|
43
|
-
type GeopointRadiusInputProps = ObjectInputProps<GeopointRadius
|
|
48
|
+
type GeopointRadiusInputProps = ObjectInputProps<GeopointRadius> & {
|
|
44
49
|
geoConfig: GoogleMapsInputConfig;
|
|
45
50
|
};
|
|
46
|
-
declare function GeopointRadiusInput(props: GeopointRadiusInputProps):
|
|
47
|
-
type DiffProps = DiffProps$3<ArrayDiff<Geopoint>>;
|
|
48
|
-
declare const GeopointArrayDiff: DiffComponent<ArrayDiff<Geopoint>>;
|
|
49
|
-
type DiffProps$1 = DiffProps$3<ObjectDiff<Geopoint>>;
|
|
50
|
-
declare const GeopointFieldDiff: DiffComponent<ObjectDiff<Geopoint>>;
|
|
51
|
-
type DiffProps$2 = DiffProps$3<ObjectDiff<GeopointRadius>>;
|
|
52
|
-
declare const GeopointRadiusFieldDiff: DiffComponent<ObjectDiff<GeopointRadius>>;
|
|
51
|
+
declare function GeopointRadiusInput(props: GeopointRadiusInputProps): import("react").JSX.Element;
|
|
53
52
|
declare const googleMapsInput: import("sanity").Plugin<GoogleMapsInputConfig>;
|
|
54
|
-
export { type Geopoint,
|
|
53
|
+
export { type Geopoint, GeopointDiff, GeopointInput, type GeopointInputProps, type GeopointRadius, GeopointRadiusInput, type GeopointRadiusInputProps, type GeopointRadiusSchemaType, type GeopointSchemaType, type GoogleMapsInputConfig, type LatLng, googleMapsInput };
|
|
55
54
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/diff/GeopointDiff.tsx","../src/types.ts","../src/input/GeopointInput.tsx","../src/input/GeopointRadiusInput.tsx","../src/plugin.tsx"],"mappings":";;AAUA;;;;;iBAAgB,YAAA;EAAc,IAAA;EAAM;AAAA,GAAa,SAAA,CAAU,UAAA,oBAAW,GAAA,CAAA,OAAA;AAAA,UCRrD,MAAA;EACf,GAAA;EACA,GAAG;AAAA;AAAA,UAGY,QAAA;EACf,KAAA;EACA,IAAA;EACA,GAAA;EACA,GAAA;EACA,GAAA;AAAA;AAAA,UAGe,cAAA;EACf,KAAA;EACA,IAAA;EACA,GAAA;EACA,GAAA;EACA,GAAA;EACA,MAAA;AAAA;AAAA,KAGU,kBAAA,GAAqB,gBAAgB;AAAA,KAErC,wBAAA,GAA2B,gBAAgB;AAAA,UAEtC,qBAAA;EACf,MAAA;EACA,WAAA;EACA,aAAA;EACA,eAAA;IACE,GAAA;IACA,GAAA;EAAA;EAEF,iBAAA;EACA,aAAA;AAAA;AAAA,KCrBU,kBAAA,GAAqB,gBAAA,CAAiB,QAAA;EAChD,SAAA,EAAW,qBAAA;AAAA;AAAA,iBAGG,aAAA,CAAc,KAAA,EAAO,kBAAkB,mBAAA,GAAA,CAAA,OAAA;AAAA,KCJ3C,wBAAA,GAA2B,gBAAA,CAAiB,cAAA;EACtD,SAAA,EAAW,qBAAA;AAAA;AAAA,iBAGG,mBAAA,CAAoB,KAAA,EAAO,wBAAwB,mBAAA,GAAA,CAAA,OAAA;AAAA,cCZtD,eAAA,mBAAe,MAAA,CAAA,qBAAA"}
|