@sanity/document-internationalization 4.0.0 → 4.1.1

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
@@ -31,12 +31,10 @@ There are two popular methods of internationalization in Sanity Studio:
31
31
  - A unique document version for every language
32
32
  - Joined together by references in a `translation.metadata` document
33
33
  - Best for documents that have unique, language-specific fields and no common content across languages
34
- - Best for translating content using Portable Text
35
34
  - **Field-level translation**
36
35
  - A single document with many languages of content
37
36
  - Achieved by mapping over languages on each field
38
37
  - Best for documents that have a mix of language-specific and common fields
39
- - Not recommended for Portable Text
40
38
 
41
39
  This plugin adds features to the Studio to improve handling **document-level translations**.
42
40
 
@@ -1 +1 @@
1
- {"version":3,"file":"resources.js","sources":["../../src/i18n/resources.ts"],"sourcesContent":["export default {\n 'action.duplicate.label': 'Duplicate with translations',\n 'action.duplicate.disabled.missing-metadata':\n 'The document cannot be duplicated because the metadata document is missing',\n 'action.duplicate.disabled.multiple-metadata':\n 'The document cannot be duplicated because there are multiple metadata documents',\n}\n"],"names":[],"mappings":";AAAA,IAAe,YAAA;AAAA,EACb,0BAA0B;AAAA,EAC1B,8CACE;AAAA,EACF,+CACE;AACJ;;"}
1
+ {"version":3,"file":"resources.js","sources":["../../src/i18n/resources.ts"],"sourcesContent":["export default {\n 'action.duplicate.label': 'Duplicate with translations',\n 'action.duplicate.disabled.missing-metadata':\n 'The document cannot be duplicated because the metadata document is missing',\n 'action.duplicate.disabled.multiple-metadata':\n 'The document cannot be duplicated because there are multiple metadata documents',\n}\n"],"names":[],"mappings":";AAAA,IAAA,YAAe;AAAA,EACb,0BAA0B;AAAA,EAC1B,8CACE;AAAA,EACF,+CACE;AACJ;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"resources.mjs","sources":["../../src/i18n/resources.ts"],"sourcesContent":["export default {\n 'action.duplicate.label': 'Duplicate with translations',\n 'action.duplicate.disabled.missing-metadata':\n 'The document cannot be duplicated because the metadata document is missing',\n 'action.duplicate.disabled.multiple-metadata':\n 'The document cannot be duplicated because there are multiple metadata documents',\n}\n"],"names":[],"mappings":"AAAA,IAAe,YAAA;AAAA,EACb,0BAA0B;AAAA,EAC1B,8CACE;AAAA,EACF,+CACE;AACJ;"}
1
+ {"version":3,"file":"resources.mjs","sources":["../../src/i18n/resources.ts"],"sourcesContent":["export default {\n 'action.duplicate.label': 'Duplicate with translations',\n 'action.duplicate.disabled.missing-metadata':\n 'The document cannot be duplicated because the metadata document is missing',\n 'action.duplicate.disabled.multiple-metadata':\n 'The document cannot be duplicated because there are multiple metadata documents',\n}\n"],"names":[],"mappings":"AAAA,IAAA,YAAe;AAAA,EACb,0BAA0B;AAAA,EAC1B,8CACE;AAAA,EACF,+CACE;AACJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"resources.esm.js","sources":["../../src/i18n/resources.ts"],"sourcesContent":["export default {\n 'action.duplicate.label': 'Duplicate with translations',\n 'action.duplicate.disabled.missing-metadata':\n 'The document cannot be duplicated because the metadata document is missing',\n 'action.duplicate.disabled.multiple-metadata':\n 'The document cannot be duplicated because there are multiple metadata documents',\n}\n"],"names":[],"mappings":"AAAA,IAAe,YAAA;AAAA,EACb,0BAA0B;AAAA,EAC1B,8CACE;AAAA,EACF,+CACE;AACJ;"}
1
+ {"version":3,"file":"resources.esm.js","sources":["../../src/i18n/resources.ts"],"sourcesContent":["export default {\n 'action.duplicate.label': 'Duplicate with translations',\n 'action.duplicate.disabled.missing-metadata':\n 'The document cannot be duplicated because the metadata document is missing',\n 'action.duplicate.disabled.multiple-metadata':\n 'The document cannot be duplicated because there are multiple metadata documents',\n}\n"],"names":[],"mappings":"AAAA,IAAA,YAAe;AAAA,EACb,0BAA0B;AAAA,EAC1B,8CACE;AAAA,EACF,+CACE;AACJ;"}
package/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import {DocumentActionComponent} from 'sanity'
4
4
  import type {FieldDefinition} from 'sanity'
5
- import {JSX as JSX_2} from 'react'
5
+ import {JSX} from 'react'
6
6
  import type {KeyedObject} from 'sanity'
7
7
  import type {ObjectSchemaType} from 'sanity'
8
8
  import {Plugin as Plugin_2} from 'sanity'
@@ -17,7 +17,7 @@ export declare const documentInternationalization: Plugin_2<PluginConfig>
17
17
 
18
18
  export declare function DocumentInternationalizationMenu(
19
19
  props: DocumentInternationalizationMenuProps
20
- ): JSX_2.Element | null
20
+ ): JSX.Element | null
21
21
 
22
22
  export declare type DocumentInternationalizationMenuProps = {
23
23
  schemaType: ObjectSchemaType
@@ -91,8 +91,7 @@ declare module 'sanity' {
91
91
  interface ArrayOptions extends DocumentInternationalizationSchemaOpts {}
92
92
  interface BlockOptions extends DocumentInternationalizationSchemaOpts {}
93
93
  interface BooleanOptions extends DocumentInternationalizationSchemaOpts {}
94
- interface CrossDatasetReferenceOptions
95
- extends DocumentInternationalizationSchemaOpts {}
94
+ interface CrossDatasetReferenceOptions extends DocumentInternationalizationSchemaOpts {}
96
95
  interface DateOptions extends DocumentInternationalizationSchemaOpts {}
97
96
  interface DatetimeOptions extends DocumentInternationalizationSchemaOpts {}
98
97
  interface FileOptions extends DocumentInternationalizationSchemaOpts {}
@@ -100,8 +99,7 @@ declare module 'sanity' {
100
99
  interface ImageOptions extends DocumentInternationalizationSchemaOpts {}
101
100
  interface NumberOptions extends DocumentInternationalizationSchemaOpts {}
102
101
  interface ObjectOptions extends DocumentInternationalizationSchemaOpts {}
103
- interface ReferenceBaseOptions
104
- extends DocumentInternationalizationSchemaOpts {}
102
+ interface ReferenceBaseOptions extends DocumentInternationalizationSchemaOpts {}
105
103
  interface SlugOptions extends DocumentInternationalizationSchemaOpts {}
106
104
  interface StringOptions extends DocumentInternationalizationSchemaOpts {}
107
105
  interface TextOptions extends DocumentInternationalizationSchemaOpts {}
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import {DocumentActionComponent} from 'sanity'
4
4
  import type {FieldDefinition} from 'sanity'
5
- import {JSX as JSX_2} from 'react'
5
+ import {JSX} from 'react'
6
6
  import type {KeyedObject} from 'sanity'
7
7
  import type {ObjectSchemaType} from 'sanity'
8
8
  import {Plugin as Plugin_2} from 'sanity'
@@ -17,7 +17,7 @@ export declare const documentInternationalization: Plugin_2<PluginConfig>
17
17
 
18
18
  export declare function DocumentInternationalizationMenu(
19
19
  props: DocumentInternationalizationMenuProps
20
- ): JSX_2.Element | null
20
+ ): JSX.Element | null
21
21
 
22
22
  export declare type DocumentInternationalizationMenuProps = {
23
23
  schemaType: ObjectSchemaType
@@ -91,8 +91,7 @@ declare module 'sanity' {
91
91
  interface ArrayOptions extends DocumentInternationalizationSchemaOpts {}
92
92
  interface BlockOptions extends DocumentInternationalizationSchemaOpts {}
93
93
  interface BooleanOptions extends DocumentInternationalizationSchemaOpts {}
94
- interface CrossDatasetReferenceOptions
95
- extends DocumentInternationalizationSchemaOpts {}
94
+ interface CrossDatasetReferenceOptions extends DocumentInternationalizationSchemaOpts {}
96
95
  interface DateOptions extends DocumentInternationalizationSchemaOpts {}
97
96
  interface DatetimeOptions extends DocumentInternationalizationSchemaOpts {}
98
97
  interface FileOptions extends DocumentInternationalizationSchemaOpts {}
@@ -100,8 +99,7 @@ declare module 'sanity' {
100
99
  interface ImageOptions extends DocumentInternationalizationSchemaOpts {}
101
100
  interface NumberOptions extends DocumentInternationalizationSchemaOpts {}
102
101
  interface ObjectOptions extends DocumentInternationalizationSchemaOpts {}
103
- interface ReferenceBaseOptions
104
- extends DocumentInternationalizationSchemaOpts {}
102
+ interface ReferenceBaseOptions extends DocumentInternationalizationSchemaOpts {}
105
103
  interface SlugOptions extends DocumentInternationalizationSchemaOpts {}
106
104
  interface StringOptions extends DocumentInternationalizationSchemaOpts {}
107
105
  interface TextOptions extends DocumentInternationalizationSchemaOpts {}
package/dist/index.esm.js CHANGED
@@ -112,7 +112,7 @@ function shallowEqualArrays(arrA, arrB, equal = (a, b) => a === b) {
112
112
  return !1;
113
113
  return !0;
114
114
  }
115
- function query$1(fn, keys = null, preload = !1, config2 = {}) {
115
+ function query$1(fn, keys = null, preload = !1, config = {}) {
116
116
  keys === null && (keys = [fn]);
117
117
  for (const entry2 of globalCache)
118
118
  if (shallowEqualArrays(keys, entry2.keys, entry2.equal)) {
@@ -121,13 +121,13 @@ function query$1(fn, keys = null, preload = !1, config2 = {}) {
121
121
  if (Object.prototype.hasOwnProperty.call(entry2, "error"))
122
122
  throw entry2.error;
123
123
  if (Object.prototype.hasOwnProperty.call(entry2, "response"))
124
- return config2.lifespan && config2.lifespan > 0 && (entry2.timeout && clearTimeout(entry2.timeout), entry2.timeout = setTimeout(entry2.remove, config2.lifespan)), entry2.response;
124
+ return config.lifespan && config.lifespan > 0 && (entry2.timeout && clearTimeout(entry2.timeout), entry2.timeout = setTimeout(entry2.remove, config.lifespan)), entry2.response;
125
125
  if (!preload)
126
126
  throw entry2.promise;
127
127
  }
128
128
  const entry = {
129
129
  keys,
130
- equal: config2.equal,
130
+ equal: config.equal,
131
131
  remove: () => {
132
132
  const index = globalCache.indexOf(entry);
133
133
  index !== -1 && globalCache.splice(index, 1);
@@ -135,14 +135,14 @@ function query$1(fn, keys = null, preload = !1, config2 = {}) {
135
135
  promise: (
136
136
  // Execute the promise
137
137
  (isPromise(fn) ? fn : fn(...keys)).then((response) => {
138
- entry.response = response, config2.lifespan && config2.lifespan > 0 && (entry.timeout = setTimeout(entry.remove, config2.lifespan));
138
+ entry.response = response, config.lifespan && config.lifespan > 0 && (entry.timeout = setTimeout(entry.remove, config.lifespan));
139
139
  }).catch((error) => entry.error = error)
140
140
  )
141
141
  };
142
142
  if (globalCache.push(entry), !preload)
143
143
  throw entry.promise;
144
144
  }
145
- const suspend = (fn, keys, config2) => query$1(fn, keys, !1, config2);
145
+ const suspend = (fn, keys, config) => query$1(fn, keys, !1, config);
146
146
  var __defProp$3 = Object.defineProperty, __defProps$2 = Object.defineProperties, __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$3 = Object.getOwnPropertySymbols, __hasOwnProp$3 = Object.prototype.hasOwnProperty, __propIsEnum$3 = Object.prototype.propertyIsEnumerable, __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$3 = (a, b) => {
147
147
  for (var prop in b || (b = {}))
148
148
  __hasOwnProp$3.call(b, prop) && __defNormalProp$3(a, prop, b[prop]);
@@ -400,13 +400,7 @@ function isSubscription(value) {
400
400
  function execFinalizer(finalizer) {
401
401
  isFunction(finalizer) ? finalizer() : finalizer.unsubscribe();
402
402
  }
403
- var config = {
404
- onUnhandledError: null,
405
- onStoppedNotification: null,
406
- Promise: void 0,
407
- useDeprecatedSynchronousErrorHandling: !1,
408
- useDeprecatedNextContext: !1
409
- }, timeoutProvider = {
403
+ var timeoutProvider = {
410
404
  setTimeout: function(handler, timeout) {
411
405
  for (var args = [], _i = 2; _i < arguments.length; _i++)
412
406
  args[_i - 2] = arguments[_i];
@@ -455,11 +449,7 @@ var Subscriber = function(_super) {
455
449
  this.unsubscribe();
456
450
  }
457
451
  }, Subscriber2;
458
- }(Subscription), _bind = Function.prototype.bind;
459
- function bind(fn, thisArg) {
460
- return _bind.call(fn, thisArg);
461
- }
462
- var ConsumerObserver = function() {
452
+ }(Subscription), ConsumerObserver = function() {
463
453
  function ConsumerObserver2(partialObserver) {
464
454
  this.partialObserver = partialObserver;
465
455
  }
@@ -494,23 +484,11 @@ var ConsumerObserver = function() {
494
484
  __extends(SafeSubscriber2, _super);
495
485
  function SafeSubscriber2(observerOrNext, error, complete) {
496
486
  var _this = _super.call(this) || this, partialObserver;
497
- if (isFunction(observerOrNext) || !observerOrNext)
498
- partialObserver = {
499
- next: observerOrNext != null ? observerOrNext : void 0,
500
- error: error != null ? error : void 0,
501
- complete: complete != null ? complete : void 0
502
- };
503
- else {
504
- var context_1;
505
- _this && config.useDeprecatedNextContext ? (context_1 = Object.create(observerOrNext), context_1.unsubscribe = function() {
506
- return _this.unsubscribe();
507
- }, partialObserver = {
508
- next: observerOrNext.next && bind(observerOrNext.next, context_1),
509
- error: observerOrNext.error && bind(observerOrNext.error, context_1),
510
- complete: observerOrNext.complete && bind(observerOrNext.complete, context_1)
511
- }) : partialObserver = observerOrNext;
512
- }
513
- return _this.destination = new ConsumerObserver(partialObserver), _this;
487
+ return isFunction(observerOrNext) || !observerOrNext ? partialObserver = {
488
+ next: observerOrNext != null ? observerOrNext : void 0,
489
+ error: error != null ? error : void 0,
490
+ complete: complete != null ? complete : void 0
491
+ } : partialObserver = observerOrNext, _this.destination = new ConsumerObserver(partialObserver), _this;
514
492
  }
515
493
  return SafeSubscriber2;
516
494
  }(Subscriber);
@@ -585,7 +563,7 @@ var OperatorSubscriber = function(_super) {
585
563
  _super(this), this.name = "EmptyError", this.message = "no elements in sequence";
586
564
  };
587
565
  });
588
- function firstValueFrom(source, config2) {
566
+ function firstValueFrom(source, config) {
589
567
  return new Promise(function(resolve, reject) {
590
568
  var subscriber = new SafeSubscriber({
591
569
  next: function(value) {
@@ -1477,8 +1455,8 @@ var metadata = (schemaTypes, metadataFields) => defineType({
1477
1455
  return a;
1478
1456
  }, __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1479
1457
  const documentInternationalization = definePlugin(
1480
- (config2) => {
1481
- const pluginConfig = __spreadValues(__spreadValues({}, DEFAULT_CONFIG), config2), {
1458
+ (config) => {
1459
+ const pluginConfig = __spreadValues(__spreadValues({}, DEFAULT_CONFIG), config), {
1482
1460
  supportedLanguages,
1483
1461
  schemaTypes,
1484
1462
  languageField,
@@ -1584,6 +1562,7 @@ const documentInternationalization = definePlugin(
1584
1562
  // Translation metadata stores its references using this plugin
1585
1563
  // It cuts down on attribute usage and gives UI conveniences to add new translations
1586
1564
  internationalizedArray({
1565
+ apiVersion: pluginConfig.apiVersion,
1587
1566
  languages: supportedLanguages,
1588
1567
  fieldTypes: [
1589
1568
  defineField(