@sanity/google-maps-input 5.0.1 → 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 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
  ![Google maps input](assets/google-maps-input.png)
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
- [![Slack Community Button](https://slack.sanity.io/badge.svg)](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
- MIT-licensed. See LICENSE.
103
+ ### Reviewing changes
127
104
 
128
- ## Develop & test
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
- Add a Google Maps API key to `.env.local` (see `.env.example` for example format).
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
- This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)
133
- with default configuration for build & watch scripts.
109
+ ```typescript
110
+ import {GeopointDiff} from '@sanity/google-maps-input'
134
111
 
135
- See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)
136
- on how to run this plugin with hotreload in the studio.
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
- ### Release new version
121
+ ## License
139
122
 
140
- Run ["CI & Release" workflow](https://github.com/sanity-io/google-maps-input/actions/workflows/main.yml).
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 { ArrayDiff, DiffComponent, DiffComponentOptions, DiffProps as DiffProps$3, ObjectDiff, ObjectInputProps, ObjectSchemaType } from "sanity";
2
- import React from "react";
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
- interface GeopointSchemaType extends ObjectSchemaType {
23
- diffComponent?: DiffComponent<ObjectDiff<Geopoint>> | DiffComponentOptions<ObjectDiff<Geopoint>>;
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, GeopointSchemaType> & {
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, GeopointRadiusSchemaType> & {
48
+ type GeopointRadiusInputProps = ObjectInputProps<GeopointRadius> & {
44
49
  geoConfig: GoogleMapsInputConfig;
45
50
  };
46
- declare function GeopointRadiusInput(props: GeopointRadiusInputProps): React.JSX.Element;
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, GeopointArrayDiff, type DiffProps as GeopointArrayDiffProps, GeopointFieldDiff, type DiffProps$1 as GeopointFieldDiffProps, GeopointInput, type GeopointInputProps, type GeopointRadius, GeopointRadiusFieldDiff, type DiffProps$2 as GeopointRadiusFieldDiffProps, GeopointRadiusInput, type GeopointRadiusInputProps, type GeopointRadiusSchemaType, type GeopointSchemaType, type GoogleMapsInputConfig, type LatLng, googleMapsInput };
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/input/GeopointInput.tsx","../src/input/GeopointRadiusInput.tsx","../src/diff/GeopointArrayDiff.tsx","../src/diff/GeopointFieldDiff.tsx","../src/diff/GeopointRadiusFieldDiff.tsx","../src/plugin.tsx"],"mappings":";;UAIiB,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,UAGe,kBAAA,SAA2B,gBAAA;EAC1C,aAAA,GAAgB,aAAA,CAAc,UAAA,CAAW,QAAA,KAAa,oBAAA,CAAqB,UAAA,CAAW,QAAA;AAAA;AAAA,UAGvE,wBAAA,SAAiC,gBAAA;EAChD,aAAA,GACI,aAAA,CAAc,UAAA,CAAW,cAAA,KACzB,oBAAA,CAAqB,UAAA,CAAW,cAAA;AAAA;AAAA,UAGrB,qBAAA;EACf,MAAA;EACA,WAAA;EACA,aAAA;EACA,eAAA;IACE,GAAA;IACA,GAAA;EAAA;EAEF,iBAAA;EACA,aAAA;AAAA;AAAA,KClBU,kBAAA,GAAqB,gBAAA,CAAiB,QAAA,EAAU,kBAAA;EAC1D,SAAA,EAAW,qBAAA;AAAA;AAAA,iBAGG,aAAA,CAAc,KAAA,EAAO,kBAAkB,mBAAA,GAAA,CAAA,OAAA;AAAA,KC6C3C,wBAAA,GAA2B,gBAAA,CACrC,cAAA,EACA,wBAAA;EAEA,SAAA,EAAW,qBAAA;AAAA;AAAA,iBAGG,mBAAA,CAAoB,KAAA,EAAO,wBAAA,GAAwB,KAAA,CAAA,GAAA,CAAA,OAAA;AAAA,KCpEvD,SAAA,GAAY,WAAA,CAAiB,SAAA,CAAU,QAAA;AAAA,cAEtC,iBAAA,EAAmB,aAAA,CAAc,SAAA,CAAU,QAAA;AAAA,KCF5C,WAAA,GAAY,WAAA,CAAiB,UAAA,CAAW,QAAA;AAAA,cAEvC,iBAAA,EAAmB,aAAA,CAAc,UAAA,CAAW,QAAA;AAAA,KCF7C,WAAA,GAAY,WAAA,CAAiB,UAAA,CAAW,cAAA;AAAA,cAEvC,uBAAA,EAAyB,aAAA,CAAc,UAAA,CAAW,cAAA;AAAA,cCVlD,eAAA,mBAAe,MAAA,CAAA,qBAAA"}
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"}